summaryrefslogtreecommitdiffstats
path: root/Lib/locale.py
diff options
context:
space:
mode:
authorJeong, YunWon <69878+youknowone@users.noreply.github.com>2023-03-30 16:23:43 (GMT)
committerGitHub <noreply@github.com>2023-03-30 16:23:43 (GMT)
commit21e9de3bf0ecf32cd61296009518bfb9fdfcd04f (patch)
tree11744c95e2c2072e04badf1c541b745a27470f13 /Lib/locale.py
parentfda95aa19447fe444ac2670afbf98ec42aca0c6f (diff)
downloadcpython-21e9de3bf0ecf32cd61296009518bfb9fdfcd04f.zip
cpython-21e9de3bf0ecf32cd61296009518bfb9fdfcd04f.tar.gz
cpython-21e9de3bf0ecf32cd61296009518bfb9fdfcd04f.tar.bz2
gh-103085: Fix python locale.getencoding not to emit deprecation warning (gh-103086)
Diffstat (limited to 'Lib/locale.py')
-rw-r--r--Lib/locale.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/locale.py b/Lib/locale.py
index c2c7a04..4127d91 100644
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -545,7 +545,9 @@ def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
"Use setlocale(), getencoding() and getlocale() instead",
DeprecationWarning, stacklevel=2
)
+ return _getdefaultlocale(envvars)
+def _getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
try:
# check if it's supported by the _locale module
import _locale
@@ -639,7 +641,7 @@ except ImportError:
# On Android langinfo.h and CODESET are missing, and UTF-8 is
# always used in mbstowcs() and wcstombs().
return 'utf-8'
- encoding = getdefaultlocale()[1]
+ encoding = _getdefaultlocale()[1]
if encoding is None:
# LANG not set, default to UTF-8
encoding = 'utf-8'