gh-123853: Update locale.windows_locale#123901
gh-123853: Update locale.windows_locale#123901serhiy-storchaka wants to merge 3 commits intopython:mainfrom
Conversation
Update the table of Windows language code identifiers (LCIDs) to protocol version 16.0 (4/23/2024).
7b80ad1 to
0b93c10
Compare
| @@ -0,0 +1,3 @@ | |||
| Update the table of Windows language code identifiers (LCIDs) used by | |||
| :func:`locale.getdefaultlocale()` on Windows to protocol version 16.0 | |||
| (4/23/2024). | |||
There was a problem hiding this comment.
| (4/23/2024). | |
| (2024-04-23). |
There was a problem hiding this comment.
This is how it is indicated in the original document.
There was a problem hiding this comment.
I understand but I dislike this date format, it's misleading. I prefer ISO 8601 date ;-)
There was a problem hiding this comment.
This is the format used on the Microsoft page. Some versions have several releases with different date (e.g. 11/14/2013, 2/13/2014 and 5/15/2014 for 6.1), so this is not redundant.
Inside the PDF document they use also other format -- v20240423. But it is not used outside of the file, so it is less suitable to identify the corresponding release.
| @@ -1467,10 +1467,15 @@ def getpreferredencoding(do_setlocale=True): | |||
| # | |||
|
|
|||
| windows_locale = { | |||
There was a problem hiding this comment.
Would it be possible to call GetLocaleInfo() instead of using a hardcoded dictionary?
There was a problem hiding this comment.
It is called. The dictionary is used if GetLocaleInfo fails to provide such information (on Windows 95, etc). That is, almost never.
And if we use GetLocaleInfo, windows_locale is not needed.
There is also better modern API than GetLocaleInfo, but since _getdefaultlocale() is deprecated anyway...
There was a problem hiding this comment.
It is called. The dictionary is used if GetLocaleInfo fails to provide such information (on Windows 95, etc)
We don't support Windows 95 anymore. Do you mean that the dict is no longer needed?
And if we use GetLocaleInfo, windows_locale is not needed.
I don't understand. getdefaultlocale() calls GetLocaleInfo() on Windows.
There was a problem hiding this comment.
Yes, I think that it is no longer needed. GetLocaleInfoA supports LOCALE_SISO639LANGNAME and LOCALE_SISO3166CTRYNAME on all modern Windows. It only returns a LCID if:
/* If we end up here, this windows version didn't know about
ISO639/ISO3166 names (it's probably Windows 95). Return the
Windows language identifier instead (a hexadecimal number) */And only in this case the dict is used.
vstinner
left a comment
There was a problem hiding this comment.
I'm not convinced that this change is needed / useful, but it looks correct to me.
I suggest to not backport this change, since it can change the behavior on programs relying the exact values.
| # http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/nls_238z.asp | ||
| # to include every locale up to Windows Vista. | ||
| # https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f | ||
| # to include every locale up to protocol revision 16.0 (4/23/2024). |
There was a problem hiding this comment.
| # to include every locale up to protocol revision 16.0 (4/23/2024). | |
| # to include every locale up to protocol revision 16.0 (2024-04-23). |
|
I only created this PR because you suggested to do this. This is actually a simplified version, it does not include names for reserved codes and ignores all parts of the name besides language and country. And it is completely useless. |
Update the table of Windows language code identifiers (LCIDs) to protocol version 16.0 (4/23/2024).
locale.windows_locale: Incorrect Windows locale for Cambodian #123853