← 返回首页
bpo-46659: Deprecate locale.getdefaultlocale() by vstinner · Pull Request #31206 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

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

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:deprecate_getdefaultlocale
Feb 22, 2022
Merged

bpo-46659: Deprecate locale.getdefaultlocale()#31206
vstinner merged 1 commit into
python:mainfrom
vstinner:deprecate_getdefaultlocale

Conversation

vstinner commented Feb 7, 2022
edited
Loading

Copy link
Copy Markdown
Member

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 changed the title bpo-43557: Deprecate locale.getdefaultlocale() bpo-46659: Deprecate locale.getdefaultlocale() Feb 8, 2022

vstinner commented Feb 8, 2022

Copy link
Copy Markdown
Member Author

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 commented Feb 8, 2022

Copy link
Copy Markdown
Member Author

cc @serhiy-storchaka @methane

methane commented Feb 9, 2022

Copy link
Copy Markdown
Member

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 commented Feb 11, 2022
edited
Loading

Copy link
Copy Markdown
Member Author

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.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

4 participants

Footer

© 2026 GitHub, Inc.