Skip to content

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

Closed
@youknowone

Description

@youknowone

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions