Skip to content

Commit 6536fab

Browse files
authored
gh-130796: Undeprecate locale.getdefaultlocale() (#143069)
1 parent c4ab024 commit 6536fab

File tree

6 files changed

+6
-21
lines changed

6 files changed

+6
-21
lines changed

Doc/deprecations/pending-removal-in-3.15.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@ Pending removal in Python 3.15
3333

3434
* ``load_module()`` method: use ``exec_module()`` instead.
3535

36-
* :class:`locale`:
37-
38-
* The :func:`~locale.getdefaultlocale` function
39-
has been deprecated since Python 3.11.
40-
Its removal was originally planned for Python 3.13 (:gh:`90817`),
41-
but has been postponed to Python 3.15.
42-
Use :func:`~locale.getlocale`, :func:`~locale.setlocale`,
43-
and :func:`~locale.getencoding` instead.
44-
(Contributed by Hugo van Kemenade in :gh:`111187`.)
45-
4636
* :mod:`pathlib`:
4737

4838
* :meth:`!.PurePath.is_reserved`

Doc/library/locale.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,6 @@ The :mod:`locale` module defines the following exception and functions:
370370
determined.
371371
The "C" locale is represented as ``(None, None)``.
372372

373-
.. deprecated-removed:: 3.11 3.15
374-
375373

376374
.. function:: getlocale(category=LC_CTYPE)
377375

Doc/whatsnew/3.15.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,9 @@ locale
562562
but included in the language code.
563563
(Contributed by Serhiy Storchaka in :gh:`137729`.)
564564

565+
* Undeprecate the :func:`locale.getdefaultlocale` function.
566+
(Contributed by Victor Stinner in :gh:`130796`.)
567+
565568

566569
math
567570
----

Lib/locale.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -559,12 +559,6 @@ def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
559559
560560
"""
561561

562-
import warnings
563-
warnings._deprecated(
564-
"locale.getdefaultlocale",
565-
"{name!r} is deprecated and slated for removal in Python {remove}. "
566-
"Use setlocale(), getencoding() and getlocale() instead.",
567-
remove=(3, 15))
568562
return _getdefaultlocale(envvars)
569563

570564

Lib/test/test_locale.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from decimal import Decimal
22
from test import support
33
from test.support import cpython_only, verbose, is_android, linked_to_musl, os_helper
4-
from test.support.warnings_helper import check_warnings
54
from test.support.import_helper import ensure_lazy_imports, import_fresh_module
65
from unittest import mock
76
import unittest
@@ -654,8 +653,7 @@ def test_defaults_UTF8(self):
654653
env.unset('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')
655654
env.set('LC_CTYPE', 'UTF-8')
656655

657-
with check_warnings(('', DeprecationWarning)):
658-
self.assertEqual(locale.getdefaultlocale(), (None, 'UTF-8'))
656+
self.assertEqual(locale.getdefaultlocale(), (None, 'UTF-8'))
659657
finally:
660658
if orig_getlocale is not None:
661659
_locale._getdefaultlocale = orig_getlocale
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Undeprecate the :func:`locale.getdefaultlocale` function.
2+
Patch by Victor Stinner.

0 commit comments

Comments
 (0)