mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-104783: Remove locale.resetlocale() function (#104784)
This commit is contained in:
parent
c7bf74bacd
commit
0cb6b9b0db
5 changed files with 8 additions and 42 deletions
|
@ -25,7 +25,7 @@ import functools
|
|||
# Yuck: LC_MESSAGES is non-standard: can't tell whether it exists before
|
||||
# trying the import. So __all__ is also fiddled at the end of the file.
|
||||
__all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error",
|
||||
"setlocale", "resetlocale", "localeconv", "strcoll", "strxfrm",
|
||||
"setlocale", "localeconv", "strcoll", "strxfrm",
|
||||
"str", "atof", "atoi", "format_string", "currency",
|
||||
"normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
|
||||
"LC_NUMERIC", "LC_ALL", "CHAR_MAX", "getencoding"]
|
||||
|
@ -612,26 +612,6 @@ def setlocale(category, locale=None):
|
|||
locale = normalize(_build_localename(locale))
|
||||
return _setlocale(category, locale)
|
||||
|
||||
def resetlocale(category=LC_ALL):
|
||||
|
||||
""" Sets the locale for category to the default setting.
|
||||
|
||||
The default setting is determined by calling
|
||||
getdefaultlocale(). category defaults to LC_ALL.
|
||||
|
||||
"""
|
||||
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:
|
||||
from _locale import getencoding
|
||||
|
@ -1729,17 +1709,6 @@ def _print_locale():
|
|||
print(' Encoding: ', enc or '(undefined)')
|
||||
print()
|
||||
|
||||
print()
|
||||
print('Locale settings after calling resetlocale():')
|
||||
print('-'*72)
|
||||
resetlocale()
|
||||
for name,category in categories.items():
|
||||
print(name, '...')
|
||||
lang, enc = getlocale(category)
|
||||
print(' Language: ', lang or '(undefined)')
|
||||
print(' Encoding: ', enc or '(undefined)')
|
||||
print()
|
||||
|
||||
try:
|
||||
setlocale(LC_ALL, "")
|
||||
except:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue