gh-123853: Cleanup Windows 95 locale fallback support#144738
gh-123853: Cleanup Windows 95 locale fallback support#144738mokurin000 wants to merge 3 commits intopython:mainfrom
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
1 similar comment
This comment was marked as resolved.
This comment was marked as resolved.
ee5da1b to
49f6613
Compare
This comment was marked as resolved.
This comment was marked as resolved.
|
cc. @malemburg @serhiy-storchaka Hi! Could you take a look on these changes? |
1e06126 to
2d24222
Compare
4f317a3 to
aa0735b
Compare
|
Are you sure that _locale._getdefaultlocale() will no longer return a Windows locale code ? |
As far as I know, Looking into git blame, the fallback code was written at 26 years ago 8f017a0, but it never get removed, and surprisingly the dictionary was maintained even after Windows 95 support were entirely removed 0a86694 |
aa0735b to
efd0a30
Compare
|
I think we should still leave a guard in the code, so that such codes do not leak outside the function. The guard should raise an exception and let the user know that something is wrong. Also, please have a look on Github whether the windows_locale is in use by Python 3 code. We may have to do a deprecation cycle (though it was already indirectly put through this as part of the now undone deprecation of getdefaultencoding()). |
With the current mechanism, if any of
Okay, I will do so soon as have time |
|
Right, undocumented though, there are many code relying on the |
1ec8e64 to
54e8f97
Compare
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Now I believe it does no impact to python users, removed the NEWS entry |
54e8f97 to
5b3e6bc
Compare
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Should not _locale._getdefaultlocale() raise an exception if the locale is not found (this should never happen on modern Windows)?
Okay, I will edit accordingly |
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
detect exception for Windows getdefaultlocale, once any of required constant was unavaliable, fall back to POSIX behaviour.
ce33482 to
6cc728a
Compare
| @@ -0,0 +1,2 @@ | |||
| Removed Windows 95 compatibility code from :func:`_locale._getdefaultlocale`. | |||
There was a problem hiding this comment.
| Removed Windows 95 compatibility code from :func:`_locale._getdefaultlocale`. | |
| Removed Windows 95 compatibility code from :func:`locale.getdefaultlocale`. |
_locale._getdefaultlocale is an implementation detail. The public interface is locale.getdefaultlocale.
| @@ -0,0 +1,2 @@ | |||
| Removed Windows 95 compatibility code from :func:`_locale._getdefaultlocale`. | |||
| Instead, if ``LOCALE_SISO639LANGNAME`` or ``LOCALE_SISO3166CTRYNAME`` cannot be retrieved, an :class:`OSError` is raised. | |||
There was a problem hiding this comment.
This is an implementation detail. And the exception should never be raised.
|
Just to clarify: If the internal API returns an OSError, the Python API should return None. With "guard" I meant that we don't allow one of these Windows locale codes to be returned by locale.getdefaultencoding() - the API is supposed to return a string or None as code. |
This removed the dead code
windows_localedict, as Windows introducedLOCALE_SISO639LANGNAMEandLOCALE_SISO3166CTRYNAMEsince Windows 98.Changes:
windows_localedict fromLib/locale.py0xfallback branch for Windows 95 or earlier inModules/_localemodule.cLib/locale.pylocale.windows_locale: Incorrect Windows locale for Cambodian #123853