]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-111187: Postpone removal version for locale.getdefaultlocale() to 3.15 (#111188)
authorHugo van Kemenade <hugovk@users.noreply.github.com>
Wed, 25 Oct 2023 13:47:41 +0000 (16:47 +0300)
committerGitHub <noreply@github.com>
Wed, 25 Oct 2023 13:47:41 +0000 (16:47 +0300)
Doc/library/locale.rst
Doc/whatsnew/3.11.rst
Doc/whatsnew/3.12.rst
Doc/whatsnew/3.13.rst
Lib/locale.py
Misc/NEWS.d/next/Library/2023-10-22-21-28-05.gh-issue-111187._W11Ab.rst [new file with mode: 0644]

index afd5677deac3f8f71c0715fdbb24f9f3decb4e51..865969e7d121b33f98a40be44b18ea55f38a2b42 100644 (file)
@@ -303,7 +303,7 @@ The :mod:`locale` module defines the following exception and functions:
    *language code* and *encoding* may be ``None`` if their values cannot be
    determined.
 
-   .. deprecated-removed:: 3.11 3.13
+   .. deprecated-removed:: 3.11 3.15
 
 
 .. function:: getlocale(category=LC_CTYPE)
index 257025da91a7ed16f9ee667a58f232ffe3a91f37..48a0e621baad0235d821ab1a5dca591de37b75a7 100644 (file)
@@ -1798,7 +1798,7 @@ Standard Library
   * :func:`importlib.resources.path`
 
 * The :func:`locale.getdefaultlocale` function is deprecated and will be
-  removed in Python 3.13. Use :func:`locale.setlocale`,
+  removed in Python 3.15. Use :func:`locale.setlocale`,
   :func:`locale.getpreferredencoding(False) <locale.getpreferredencoding>` and
   :func:`locale.getlocale` functions instead.
   (Contributed by Victor Stinner in :gh:`90817`.)
index dc0cc82475a2e4531e9e55618363aa88194963ad..36d12feebea79b0d75430d9b1b3ee46f0df55ca1 100644 (file)
@@ -1360,7 +1360,6 @@ Other modules:
 APIs:
 
 * :class:`!configparser.LegacyInterpolation` (:gh:`90765`)
-* :func:`locale.getdefaultlocale` (:gh:`90817`)
 * ``locale.resetlocale()`` (:gh:`90817`)
 * :meth:`!turtle.RawTurtle.settiltangle` (:gh:`50096`)
 * :func:`!unittest.findTestCases` (:gh:`50096`)
@@ -1430,6 +1429,17 @@ and will be removed in Python 3.14.
 
 * The ``co_lnotab`` attribute of code objects.
 
+Pending Removal in Python 3.15
+------------------------------
+
+The following APIs have been deprecated
+and will be removed in Python 3.15.
+
+APIs:
+
+* :func:`locale.getdefaultlocale` (:gh:`90817`)
+
+
 Pending Removal in Future Versions
 ----------------------------------
 
index a514659e383e4b0eeb6159b5d1c51558348f8841..1053aa5729ede41db33354650ad191086537ef9d 100644 (file)
@@ -500,6 +500,13 @@ Pending Removal in Python 3.15
   rarely used.  No direct replacement exists.  *Anything* is better than CGI
   to interface a web server with a request handler.
 
+* :class:`locale`: :func:`locale.getdefaultlocale` was deprecated in Python 3.11
+  and originally planned for removal in Python 3.13 (:gh:`90817`),
+  but removal has been postponed to Python 3.15.
+  Use :func:`locale.setlocale()`, :func:`locale.getencoding()` and
+  :func:`locale.getlocale()` instead.
+  (Contributed by Hugo van Kemenade in :gh:`111187`.)
+
 * :class:`typing.NamedTuple`:
 
   * The undocumented keyword argument syntax for creating NamedTuple classes
@@ -612,10 +619,6 @@ although there is currently no date scheduled for their removal.
   <https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy>`_
   for migration advice.
 
-* :func:`locale.getdefaultlocale`: use :func:`locale.setlocale()`,
-  :func:`locale.getencoding()` and :func:`locale.getlocale()` instead
-  (:gh:`90817`)
-
 * :mod:`mailbox`: Use of StringIO input and text mode is deprecated, use
   BytesIO and binary mode instead.
 
index 55c819ca80a1604d88f5a266751d82c555f3e964..e0cb4c5449d5567f4984bd0affa8ae3a33a4765b 100644 (file)
@@ -541,12 +541,14 @@ def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
     """
 
     import warnings
-    warnings.warn(
-        "Use setlocale(), getencoding() and getlocale() instead",
-        DeprecationWarning, stacklevel=2
-    )
+    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)
 
+
 def _getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
     try:
         # check if it's supported by the _locale module
diff --git a/Misc/NEWS.d/next/Library/2023-10-22-21-28-05.gh-issue-111187._W11Ab.rst b/Misc/NEWS.d/next/Library/2023-10-22-21-28-05.gh-issue-111187._W11Ab.rst
new file mode 100644 (file)
index 0000000..dc24243
--- /dev/null
@@ -0,0 +1 @@
+Postpone removal version for locale.getdefaultlocale() to Python 3.15.