From 212e034988f757a37b4ab6815f86e701fd4e27e3 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 23 Dec 2025 16:31:10 +0100 Subject: [PATCH] [3.13] gh-130796: Undeprecate locale.getdefaultlocale() (GH-143069) (cherry picked from commit 6536fab19410ce701575b553d381cf805d3ef323) Co-authored-by: Victor Stinner --- Doc/deprecations/pending-removal-in-3.15.rst | 10 ---------- Doc/library/locale.rst | 2 -- Lib/locale.py | 6 ------ Lib/test/test_locale.py | 4 +--- .../2025-12-23-11-43-05.gh-issue-130796.TkzUGx.rst | 2 ++ 5 files changed, 3 insertions(+), 21 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2025-12-23-11-43-05.gh-issue-130796.TkzUGx.rst diff --git a/Doc/deprecations/pending-removal-in-3.15.rst b/Doc/deprecations/pending-removal-in-3.15.rst index 3b0ecb873ecff8b..fc085d173438b77 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 14a8ec725ec4d20..5807a05ea2e0d9b 100644 --- a/Doc/library/locale.rst +++ b/Doc/library/locale.rst @@ -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) diff --git a/Lib/locale.py b/Lib/locale.py index bcb6ac0f49a9c4a..b31e7afc35a6ab6 100644 --- a/Lib/locale.py +++ b/Lib/locale.py @@ -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) diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py index 71d03f3a3f904b0..9ab1f869b4a25fb 100644 --- a/Lib/test/test_locale.py +++ b/Lib/test/test_locale.py @@ -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 @@ def test_defaults_UTF8(self): 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 index 000000000000000..a078561a1014faa --- /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.