diff options
Diffstat (limited to 'Lib/locale.py')
-rw-r--r-- | Lib/locale.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/Lib/locale.py b/Lib/locale.py index 3dc4caf..58cf0a7 100644 --- a/Lib/locale.py +++ b/Lib/locale.py @@ -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')): |