mirror of
https://github.com/python/cpython.git
synced 2025-11-25 12:44:13 +00:00
Issue #3067: Fix the error raised by locale.setlocale()
This commit is contained in:
parent
12b66b5217
commit
3c85fe07f4
4 changed files with 23 additions and 7 deletions
|
|
@ -440,13 +440,17 @@ def _build_localename(localetuple):
|
|||
No aliasing or normalizing takes place.
|
||||
|
||||
"""
|
||||
language, encoding = localetuple
|
||||
if language is None:
|
||||
language = 'C'
|
||||
if encoding is None:
|
||||
return language
|
||||
else:
|
||||
return language + '.' + encoding
|
||||
try:
|
||||
language, encoding = localetuple
|
||||
|
||||
if language is None:
|
||||
language = 'C'
|
||||
if encoding is None:
|
||||
return language
|
||||
else:
|
||||
return language + '.' + encoding
|
||||
except (TypeError, ValueError):
|
||||
raise TypeError('Locale must be None, a string, or an iterable of two strings -- language code, encoding.')
|
||||
|
||||
def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue