https://github.com/python/cpython/commit/6536fab19410ce701575b553d381cf805d3ef323
commit: 6536fab19410ce701575b553d381cf805d3ef323
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2025-12-23T16:31:10+01:00
summary:
gh-130796: Undeprecate locale.getdefaultlocale() (#143069)
files:
A Misc/NEWS.d/next/Library/2025-12-23-11-43-05.gh-issue-130796.TkzUGx.rst
M Doc/deprecations/pending-removal-in-3.15.rst
M Doc/library/locale.rst
M Doc/whatsnew/3.15.rst
M Lib/locale.py
M Lib/test/test_locale.py
diff --git a/Doc/deprecations/pending-removal-in-3.15.rst
b/Doc/deprecations/pending-removal-in-3.15.rst
index 3b9cf892fe913d..00266b1725c8a1 100644
--- a/Doc/deprecations/pending-removal-in-3.15.rst
+++ b/Doc/deprecations/pending-removal-in-3.15.rst
@@ -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`
diff --git a/Doc/library/locale.rst b/Doc/library/locale.rst
index ce025670c92999..00dd616830bf55 100644
--- a/Doc/library/locale.rst
+++ b/Doc/library/locale.rst
@@ -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)
diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst
index aa138c9cacb021..b1b533d8cde014 100644
--- a/Doc/whatsnew/3.15.rst
+++ b/Doc/whatsnew/3.15.rst
@@ -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
----
diff --git a/Lib/locale.py b/Lib/locale.py
index 0f1b429ea419b0..dea3ee55cf4d24 100644
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -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)
diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py
index d49f78c91da1b3..a06c600cf56689 100644
--- a/Lib/test/test_locale.py
+++ b/Lib/test/test_locale.py
@@ -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 @@ def test_defaults_UTF8(self):
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
index 00000000000000..a078561a1014fa
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-12-23-11-43-05.gh-issue-130796.TkzUGx.rst
@@ -0,0 +1,2 @@
+Undeprecate the :func:`locale.getdefaultlocale` function.
+Patch by Victor Stinner.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]