Skip to content

Commit 06dce35

Browse files
hugovkvstinner
andauthored
[3.13] gh-130796: Undeprecate locale.getdefaultlocale() (GH-143069) (#151318)
Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 003db2f commit 06dce35

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
@@ -358,8 +358,6 @@ The :mod:`locale` module defines the following exception and functions:
358358
determined.
359359
The "C" locale is represented as ``(None, None)``.
360360

361-
.. deprecated-removed:: 3.11 3.15
362-
363361

364362
.. function:: getlocale(category=LC_CTYPE)
365363

Lib/locale.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -540,12 +540,6 @@ def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
540540
541541
"""
542542

543-
import warnings
544-
warnings._deprecated(
545-
"locale.getdefaultlocale",
546-
"{name!r} is deprecated and slated for removal in Python {remove}. "
547-
"Use setlocale(), getencoding() and getlocale() instead.",
548-
remove=(3, 15))
549543
return _getdefaultlocale(envvars)
550544

551545

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 verbose, is_android, is_emscripten, is_wasi
3-
from test.support.warnings_helper import check_warnings
43
from test.support.import_helper import import_fresh_module
54
from unittest import mock
65
import unittest
@@ -560,8 +559,7 @@ def test_defaults_UTF8(self):
560559

561560
os.environ['LC_CTYPE'] = 'UTF-8'
562561

563-
with check_warnings(('', DeprecationWarning)):
564-
self.assertEqual(locale.getdefaultlocale(), (None, 'UTF-8'))
562+
self.assertEqual(locale.getdefaultlocale(), (None, 'UTF-8'))
565563

566564
finally:
567565
for k in orig_env:
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)