Visitar URL original
bpo-46659: Deprecate locale.getdefaultlocale() by vstinner · Pull Request #31206 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20221223134818/https://github.com/python/cpython/pull/31206
Skip to content
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

bpo-46659: Deprecate locale.getdefaultlocale() #31206

Merged
merged 1 commit into from Feb 22, 2022

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Feb 7, 2022 •

The locale.getdefaultlocale() function is deprecated and will be removed in
Python 3.13. Use locale.setlocale(),
locale.getpreferredencoding(False) and locale.getlocale() functions
instead.

https://bugs.python.org/issue46659

@vstinner vstinner force-pushed the deprecate_getdefaultlocale branch from 36fcd97 to 526a4ee Compare Feb 8, 2022
@vstinner vstinner changed the title bpo-43557: Deprecate locale.getdefaultlocale() bpo-46659: Deprecate locale.getdefaultlocale() Feb 8, 2022
@vstinner
Copy link
Member Author

vstinner commented Feb 8, 2022

cc @malemburg

The locale.getdefaultlocale() function is deprecated and will be
removed in Python 3.13. Use locale.setlocale(),
locale.getpreferredencoding(False) and locale.getlocale() functions
instead.
@vstinner vstinner force-pushed the deprecate_getdefaultlocale branch from 526a4ee to abe8f1e Compare Feb 8, 2022
@vstinner
Copy link
Member Author

vstinner commented Feb 8, 2022

cc @serhiy-storchaka @methane

@methane
Copy link
Member

methane commented Feb 9, 2022

Locale is too difficult to me, so I can not say LGTM.
At least, I feel it is very tempting API that can be used to get preferred language without calling setlocale()...

@vstinner
Copy link
Member Author

vstinner commented Feb 11, 2022 •

At least, I feel it is very tempting API that can be used to get preferred language without calling setlocale()...

The function is convenient until you fall into a case where it doesn't work as expected. It's similar to mixing Python 2 str and unicode types. It works in most cases, until someone enters a name with a single non-ASCII character, and then suddently everything fall apart.

@vstinner vstinner merged commit b899126 into python:main Feb 22, 2022
12 checks passed
@vstinner vstinner deleted the deprecate_getdefaultlocale branch Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants