8000 gh-111187: Postpone removal version for locale.getdefaultlocale() to … · python/cpython@81ed80d · GitHub
[go: up one dir, main page]

Skip to content

Commit 81ed80d

Browse files
authored
gh-111187: Postpone removal version for locale.getdefaultlocale() to 3.15 (#111188)
1 parent f630494 commit 81ed80d

File tree

6 files changed

+27
-11
lines changed

6 files changed

+27
-11
lines changed

Doc/library/locale.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ The :mod:`locale` module defines the following exception and functions:
303303
*language code* and *encoding* may be ``None`` if their values cannot be
304304
determined.
305305

306-
.. deprecated-removed:: 3.11 3.13
306+
.. deprecated-removed:: 3.11 3.15
307307

308308

309309
.. function:: getlocale(category=LC_CTYPE)

Doc/whatsnew/3.11.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1798,7 +1798,7 @@ Standard Library
17981798
* :func:`importlib.resources.path`
17991799

18001800
* The :func:`locale.getdefaultlocale` function is deprecated and will be
1801-
removed in Python 3.13. Use :func:`locale.setlocale`,
1801+
removed in Python 3.15. Use :func:`locale.setlocale`,
18021802
:func:`locale.getpreferredencoding(False) <locale.getpreferredencoding>` and
18031803
:func:`locale.getlocale` functions instead.
18041804
(Contributed by Victor Stinner in :gh:`90817`.)

Doc/whatsnew/3.12.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,6 @@ Other modules:
13601360
APIs:
13611361

13621362
* :class:`!configparser.LegacyInterpolation` (:gh:`90765`)
1363-
* :func:`locale.getdefaultlocale` (:gh:`90817`)
13641363
* ``locale.resetlocale()`` (:gh:`90817`)
13651364
* :meth:`!turtle.RawTurtle.settiltangle` (:gh:`50096`)
13661365
* :func:`!unittest.findTestCases` (:gh:`50096`)
@@ -1430,6 +1429,17 @@ and will be removed in Python 3.14.
14301429

14311430
* The ``co_lnotab`` attribute of code objects.
14321431

1432+
Pending Removal in Python 3.15
1433+
------------------------------
1434+
1435+
The following APIs have been deprecated
1436+
and will be removed in Python 3.15.
1437+
1438+
APIs:
1439+
1440+
* :func:`locale.getdefaultlocale` (:gh:`90817`)
1441+
1442+
14331443
Pending Removal in Future Versions
14341444
----------------------------------
14351445

Doc/whatsnew/3.13.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,13 @@ Pending Removal in Python 3.15
500500
rarely used. No direct replacement exists. *Anything* is better than CGI
501501
to interface a web server with a request handler.
502502

503+
* :class:`locale`: :func:`locale.getdefaultlocale` was deprecated in Python 3.11
504+
and originally planned for removal in Python 3.13 (:gh:`90817`),
505+
but removal has been postponed to Python 3.15.
506+
Use :func:`locale.setlocale()`, :func:`locale.getencoding()` and
507+
:func:`locale.getlocale()` instead.
508+
(Contributed by Hugo van Kemenade in :gh:`111187`.)
509+
503510
* :class:`typing.NamedTuple`:
504511

505512
* The undocumented keyword argument syntax for creating NamedTuple classes
@@ -612,10 +619,6 @@ although there is currently no date scheduled for their removal.
612619
<https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy>`_
613620
for migration advice.
614621

615-
* :func:`locale.getdefaultlocale`: use :func:`locale.setlocale()`,
616-
:func:`locale.getencoding()` and :func:`locale.getlocale()` instead
617-
(:gh:`90817`)
618-
619622
* :mod:`mailbox`: Use of StringIO input and text mode is deprecated, use
620623
BytesIO and binary mode instead.
621624

Lib/locale.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
541541
"""
542542

543543
import warnings
544-
warnings.warn(
545-
"Use setlocale(), getencoding() and getlocale() instead",
546-
DeprecationWarning, stacklevel=2
547-
)
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))
548549
return _getdefaultlocale(envvars)
549550

551+
550552
def _getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
551553
try:
552554
# check if it's supported by the _locale module
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Postpone removal version for locale.getdefaultlocale() to Python 3.15.

0 commit comments

Comments
 (0)
0