Skip to content

python version locale.getencoding() warns deprecation and advice to use getencoding() again #103085

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

Closed
youknowone opened this issue Mar 28, 2023 · 0 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@youknowone
Copy link
Contributor

youknowone commented Mar 28, 2023

Bug report

When calling locale.getencoding() while _locale.getencoding() is not available, it shows looking-recursive deprecation warnings.

../Lib/locale.py:657: DeprecationWarning: Use setlocale(), getencoding() and getlocale() instead

This is happening because python version locale.getencoding() is calling locale.getdefaultlocale() https://github.com/python/cpython/blob/v3.12.0a5/Lib/locale.py#L642

and locale.getdefaultlocale warns regardless where the call came from

https://github.com/python/cpython/blob/v3.12.0a5/Lib/locale.py#L544-L547

Your environment

  • CPython versions tested on: v3.11.2 Lib with RustPython HEAD
  • Operating system and architecture: aarch64-apple-darwin

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants