gh-123853: Update locale.windows_locale#123901
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.
There was a problem hiding this comment.
Same comment as above. Just like we use UTF-8 in more and more places, we should use ISO dates in more and more places.
There was a problem hiding this comment.
This is a good argument.
| @@ -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.
There was a problem hiding this comment.
I think this is irrelevant. First, it's always good to have a fallback solution and second I do believe that this dict is used directly by people in their code for other purposes as well. It's been available for a very long time.
If we want to get rid off it, it should be properly deprecated first.
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). |
There was a problem hiding this comment.
Agreed, let's stick with ISO dates.
|
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. |
|
This PR is stale because it has been open for 30 days with no activity. |
malemburg
left a comment
There was a problem hiding this comment.
LGTM, modulo the minor date format changes.
| # 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.
Agreed, let's stick with ISO dates.
| @@ -1467,10 +1467,15 @@ def getpreferredencoding(do_setlocale=True): | |||
| # | |||
|
|
|||
| windows_locale = { | |||
There was a problem hiding this comment.
I think this is irrelevant. First, it's always good to have a fallback solution and second I do believe that this dict is used directly by people in their code for other purposes as well. It's been available for a very long time.
If we want to get rid off it, it should be properly deprecated first.
| @@ -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.
Same comment as above. Just like we use UTF-8 in more and more places, we should use ISO dates in more and more places.
|
If we accept this change, I think that it should be backported. The original issue was that some names were incorrect. This PR was created before adding support for @-modifiers. So it maps some codes for different locales to the same name, because this what was supported at that time. For example, Cyrillic and Latin variants of Serbian are mapped to the same name, as well as Traditional and Simplified Chinese. If this PR was backported, I am going to create a follow up PR which preserves distinction. Or I can modify this PR. |
|
Ah, I have not yet finished support of @-modifiers on Windows. It is my drafts. So this is a separate issue. |
|
|
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