summaryrefslogtreecommitdiffstats
path: root/Lib/locale.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-05-25 20:04:06 (GMT)
committerGitHub <noreply@github.com>2022-05-25 20:04:06 (GMT)
commitbf58cd01b313837511d9399f18588ccd2e5dc5a9 (patch)
treea80d7beab81640cee2c4ee77ffff6f179d2fa2d2 /Lib/locale.py
parent854db1a6061c83d80a3f1e4e87f043b521719920 (diff)
downloadcpython-bf58cd01b313837511d9399f18588ccd2e5dc5a9.zip
cpython-bf58cd01b313837511d9399f18588ccd2e5dc5a9.tar.gz
cpython-bf58cd01b313837511d9399f18588ccd2e5dc5a9.tar.bz2
gh-90817: Deprecate explicitly locale.resetlocale() (#93196)
The function was already deprecated in Python 3.11 since it calls locale.getdefaultlocale() which was deprecated in Python 3.11.
Diffstat (limited to 'Lib/locale.py')
-rw-r--r--Lib/locale.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/locale.py b/Lib/locale.py
index 25eb75ac..7a7694e 100644
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -633,7 +633,17 @@ def resetlocale(category=LC_ALL):
getdefaultlocale(). category defaults to LC_ALL.
"""
- _setlocale(category, _build_localename(getdefaultlocale()))
+ import warnings
+ warnings.warn(
+ 'Use locale.setlocale(locale.LC_ALL, "") instead',
+ DeprecationWarning, stacklevel=2
+ )
+
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', category=DeprecationWarning)
+ loc = getdefaultlocale()
+
+ _setlocale(category, _build_localename(loc))
try: