]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-130796: Undeprecate locale.getdefaultlocale() (#143069)
authorVictor Stinner <vstinner@python.org>
Tue, 23 Dec 2025 15:31:10 +0000 (16:31 +0100)
committerGitHub <noreply@github.com>
Tue, 23 Dec 2025 15:31:10 +0000 (16:31 +0100)
Doc/deprecations/pending-removal-in-3.15.rst
Doc/library/locale.rst
Doc/whatsnew/3.15.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 3b9cf892fe913d8a9f48e27b8d8d996d23df996f..00266b1725c8a1b1f3e8f4cc60f8a3ae48956890 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 ce025670c929992fb80f135783a39dcdc2d38ddd..00dd616830bf55f8079984aa43e62d3e0cb25ca0 100644 (file)
@@ -370,8 +370,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 aa138c9cacb02117226771ab42017a3b7baf05d9..b1b533d8cde014f267424c68d0dc65e30fc7c1ff 100644 (file)
@@ -562,6 +562,9 @@ locale
   but included in the language code.
   (Contributed by Serhiy Storchaka in :gh:`137729`.)
 
+* Undeprecate the :func:`locale.getdefaultlocale` function.
+  (Contributed by Victor Stinner in :gh:`130796`.)
+
 
 math
 ----
index 0f1b429ea419b02965184836726123985aa437ae..dea3ee55cf4d24c24de082d55731f61327a729c0 100644 (file)
@@ -559,12 +559,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 d49f78c91da1b30f1a8a7d2b0277c86cbba2563f..a06c600cf56689e5c21722e23268405eebbd623e 100644 (file)
@@ -1,7 +1,6 @@
 from decimal import Decimal
 from test import support
 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
@@ -654,8 +653,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.