Skip to content

Commit 58c6e78

Browse files
hugovkvstinner
andauthored
[3.14] gh-130796: Undeprecate locale.getdefaultlocale() (GH-143069) (#151317)
Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent a258c96 commit 58c6e78

5 files changed

Lines changed: 3 additions & 21 deletions

File tree

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
@@ -367,8 +367,6 @@ The :mod:`!locale` module defines the following exception and functions:
367367
determined.
368368
The "C" locale is represented as ``(None, None)``.
369369

370-
.. deprecated-removed:: 3.11 3.15
371-
372370

373371
.. function:: getlocale(category=LC_CTYPE)
374372

Lib/locale.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -545,12 +545,6 @@ def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
545545
546546
"""
547547

548-
import warnings
549-
warnings._deprecated(
550-
"locale.getdefaultlocale",
551-
"{name!r} is deprecated and slated for removal in Python {remove}. "
552-
"Use setlocale(), getencoding() and getlocale() instead.",
553-
remove=(3, 15))
554548
return _getdefaultlocale(envvars)
555549

556550

Lib/test/test_locale.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from decimal import Decimal
22
from test.support import cpython_only, verbose, is_android, linked_to_musl, os_helper
3-
from test.support.warnings_helper import check_warnings
43
from test.support.import_helper import ensure_lazy_imports, import_fresh_module
54
from unittest import mock
65
import unittest
@@ -554,8 +553,7 @@ def test_defaults_UTF8(self):
554553
env.unset('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')
555554
env.set('LC_CTYPE', 'UTF-8')
556555

557-
with check_warnings(('', DeprecationWarning)):
558-
self.assertEqual(locale.getdefaultlocale(), (None, 'UTF-8'))
556+
self.assertEqual(locale.getdefaultlocale(), (None, 'UTF-8'))
559557
finally:
560558
if orig_getlocale is not None:
561559
_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)