*language code* and *encoding* may be ``None`` if their values cannot be
determined.
+ .. deprecated:: 3.11 3.13
+
.. function:: getlocale(category=LC_CTYPE)
(Contributed by Hugo van Kemenade in :issue:`45173`.)
+* The :func:`locale.getdefaultlocale` function is deprecated and will be
+ removed in Python 3.13. Use :func:`locale.setlocale`,
+ :func:`locale.getpreferredencoding(False) <locale.getpreferredencoding>` and
+ :func:`locale.getlocale` functions instead.
+ (Contributed by Victor Stinner in :issue:`46659`.)
+
Removed
=======
"""
+ import warnings
+ warnings.warn(
+ "Use setlocale(), getpreferredencoding(False) and getlocale() instead",
+ DeprecationWarning, stacklevel=2
+ )
+
try:
# check if it's supported by the _locale module
import _locale
os.environ['LC_CTYPE'] = 'UTF-8'
- self.assertEqual(locale.getdefaultlocale(), (None, 'UTF-8'))
+ with check_warnings(('', DeprecationWarning)):
+ self.assertEqual(locale.getdefaultlocale(), (None, 'UTF-8'))
finally:
for k in orig_env:
--- /dev/null
+The :func:`locale.getdefaultlocale` function is deprecated and will be removed
+in Python 3.13. Use :func:`locale.setlocale`,
+:func:`locale.getpreferredencoding(False) <locale.getpreferredencoding>` and
+:func:`locale.getlocale` functions instead. Patch by Victor Stinner.