]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-130796: Undeprecate locale.getdefaultlocale() (GH-143069) (#151317)
authorHugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Thu, 11 Jun 2026 11:34:21 +0000 (14:34 +0300)
committerGitHub <noreply@github.com>
Thu, 11 Jun 2026 11:34:21 +0000 (14:34 +0300)
Co-authored-by: Victor Stinner <vstinner@python.org>
Doc/deprecations/pending-removal-in-3.15.rst
Doc/library/locale.rst
Lib/locale.py
Lib/test/test_locale.py
Misc/NEWS.d/next/Library/2025-12-23-11-43-05.gh-issue-130796.TkzUGx.rst [new file with mode: 0644]

index 600510cf7f00f8a0454770d2960268b03e09b529..814c6904d3e2ab95191ba75c512e80144735a2f6 100644 (file)
@@ -33,16 +33,6 @@ Pending removal in Python 3.15
 
   * ``load_module()`` method: use ``exec_module()`` instead.
 
-* :class:`locale`:
-
-  * The :func:`~locale.getdefaultlocale` function
-    has been deprecated since Python 3.11.
-    Its removal was originally planned for Python 3.13 (:gh:`90817`),
-    but has been postponed to Python 3.15.
-    Use :func:`~locale.getlocale`, :func:`~locale.setlocale`,
-    and :func:`~locale.getencoding` instead.
-    (Contributed by Hugo van Kemenade in :gh:`111187`.)
-
 * :mod:`pathlib`:
 
   * :meth:`.PurePath.is_reserved`
index 81ac46eea871b1d8648d583c8374e9cce9d3df30..c2c4a0e269de9914cbfd67e8e012cd76a2eb640d 100644 (file)
@@ -367,8 +367,6 @@ The :mod:`!locale` module defines the following exception and functions:
    determined.
    The "C" locale is represented as ``(None, None)``.
 
-   .. deprecated-removed:: 3.11 3.15
-
 
 .. function:: getlocale(category=LC_CTYPE)
 
index 498af087354c3d2255a3561c1f17942fc45607bb..6984a6a5e2bc187206484ba173ccbe59b28ad93f 100644 (file)
@@ -545,12 +545,6 @@ def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
 
     """
 
-    import warnings
-    warnings._deprecated(
-        "locale.getdefaultlocale",
-        "{name!r} is deprecated and slated for removal in Python {remove}. "
-        "Use setlocale(), getencoding() and getlocale() instead.",
-        remove=(3, 15))
     return _getdefaultlocale(envvars)
 
 
index 8e49aa8954ee0d0eee45af1ab6d58c908776ab40..f91843562c30fc5721c4f697af64a1582a6bee41 100644 (file)
@@ -1,6 +1,5 @@
 from decimal import Decimal
 from test.support import cpython_only, verbose, is_android, linked_to_musl, os_helper
-from test.support.warnings_helper import check_warnings
 from test.support.import_helper import ensure_lazy_imports, import_fresh_module
 from unittest import mock
 import unittest
@@ -554,8 +553,7 @@ class TestMiscellaneous(unittest.TestCase):
                 env.unset('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')
                 env.set('LC_CTYPE', 'UTF-8')
 
-                with check_warnings(('', DeprecationWarning)):
-                    self.assertEqual(locale.getdefaultlocale(), (None, 'UTF-8'))
+                self.assertEqual(locale.getdefaultlocale(), (None, 'UTF-8'))
         finally:
             if orig_getlocale is not None:
                 _locale._getdefaultlocale = orig_getlocale
diff --git a/Misc/NEWS.d/next/Library/2025-12-23-11-43-05.gh-issue-130796.TkzUGx.rst b/Misc/NEWS.d/next/Library/2025-12-23-11-43-05.gh-issue-130796.TkzUGx.rst
new file mode 100644 (file)
index 0000000..a078561
--- /dev/null
@@ -0,0 +1,2 @@
+Undeprecate the :func:`locale.getdefaultlocale` function.
+Patch by Victor Stinner.