gh-103085: Fix python locale.getencoding not to emit deprecation warning (gh-103086)

This commit is contained in:
Jeong, YunWon 2023-03-31 01:23:43 +09:00 committed by GitHub
parent fda95aa194
commit 21e9de3bf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -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'

View File

@ -0,0 +1 @@
Pure python :func:`locale.getencoding()` will not warn deprecation.