]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-130796: Undeprecate locale.getdefaultlocale() (GH-143069) (#151318)
authorHugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Thu, 11 Jun 2026 11:34:40 +0000 (14:34 +0300)
committerGitHub <noreply@github.com>
Thu, 11 Jun 2026 11:34:40 +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 3b0ecb873ecff8b273402ab411584775f3423b35..fc085d173438b779f356388b5a215b781cab8942 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 14a8ec725ec4d204de848c67dec59148353c1592..5807a05ea2e0d9bbcb7c87fc5deed8fe095aa2c2 100644 (file)
@@ -358,8 +358,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 bcb6ac0f49a9c4a4f740fcb8f7d1b7926f22bd21..b31e7afc35a6ab6c531bd003ada671ec06f0b583 100644 (file)
@@ -540,12 +540,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 71d03f3a3f904b00b8fcb5db3e5f4fae3045339f..9ab1f869b4a25fb83b25d287be44ba1b286b789b 100644 (file)
@@ -1,6 +1,5 @@
 from decimal import Decimal
 from test.support import verbose, is_android, is_emscripten, is_wasi
-from test.support.warnings_helper import check_warnings
 from test.support.import_helper import import_fresh_module
 from unittest import mock
 import unittest
@@ -560,8 +559,7 @@ class TestMiscellaneous(unittest.TestCase):
 
             os.environ['LC_CTYPE'] = 'UTF-8'
 
-            with check_warnings(('', DeprecationWarning)):
-                self.assertEqual(locale.getdefaultlocale(), (None, 'UTF-8'))
+            self.assertEqual(locale.getdefaultlocale(), (None, 'UTF-8'))
 
         finally:
             for k in orig_env:
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.