-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-123853: Update locale.windows_locale #123901
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(4/23/2024). | |
(2024-04-23). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how it is indicated in the original document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand but I dislike this date format, it's misleading. I prefer ISO 8601 date ;-)
@@ -1467,10 +1467,15 @@ def getpreferredencoding(do_setlocale=True): | |||
# | |||
|
|||
windows_locale = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to call GetLocaleInfo() instead of using a hardcoded dictionary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# 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