8000 gh-103085: Fix python locale.getencoding not to emit deprecation warn… · python/cpython@21e9de3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 21e9de3

Browse files
authored
gh-103085: Fix python locale.getencoding not to emit deprecation warning (gh-103086)
1 parent fda95aa commit 21e9de3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Lib/locale.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,9 @@ def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
545545
"Use setlocale(), getencoding() and getlocale() instead",
546546
DeprecationWarning, stacklevel=2
547547
)
548+
return _getdefaultlocale(envvars)
548549

550+
def _getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
549551
try:
550552
# check if it's supported by the _locale module
551553
import _locale
@@ -639,7 +641,7 @@ def getencoding():
639641
# On Android langinfo.h and CODESET are missing, and UTF-8 is
640642
# always used in mbstowcs() and wcstombs().
641643
return 'utf-8'
642-
encoding = getdefaultlocale()[1]
644+
encoding = _getdefaultlocale()[1]
643645
if encoding is None:
644646
# LANG not set, default to UTF-8
645647
encoding = 'utf-8'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Pure python :func:`locale.getencoding()` will not warn deprecation.

0 commit comments

Comments
 (0)
0