Skip to content

locale.getdefaultlocale() is deprecated #249

@bcbnz

Description

@bcbnz

The locale.getdefaultlocale() function was deprecated in Python 3.11 and will be removed in 3.13 (see the note in the library docs). The deprecation warning issued when running says use setlocale(), getencoding() and getlocale() instead.

The only place it is used is crypto/encoding.py:

def get_system_encoding():
"""
The encoding of the default system locale. Fallback to 'ascii' if the
#encoding is unsupported by Python or could not be determined. See tickets
#10335 and #5846.
"""
try:
encoding = locale.getdefaultlocale()[1] or "ascii"
codecs.lookup(encoding)
except Exception:
encoding = "ascii"
return encoding

I guess either locale.getencoding() or locale.getpreferredencoding would be a suitable replacement.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions