This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: locale.setlocale checks locale name for string incorrectly
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Saulius Žemaitaitis, lemburg, loewis
Priority: normal Keywords:

Created on 2015-03-22 15:36 by Saulius Žemaitaitis, last changed 2022-04-11 14:58 by admin.

Messages (2)
msg238914 - (view) Author: Saulius Žemaitaitis (Saulius Žemaitaitis) Date: 2015-03-22 15:36
Steps to reproduce:

python2.7 -c "import locale; locale.setlocale(locale.LC_ALL, u'en_US')"

Raises: ValueError: too many values to unpack

Problem lies in locale.py file from the standard library. It checks if locale is string incorrectly:

    if locale and type(locale) is not type(""):
        # convert to string
        locale = normalize(_build_localename(locale))

I think it should instead check if locale is basestring:

    locale and not isinstance(locale, basestring):
        # <..>

If above fix looks correct I'll submit it as a patch.
msg238915 - (view) Author: Saulius Žemaitaitis (Saulius Žemaitaitis) Date: 2015-03-22 15:39
Python 2.7.9 (default, Jan 29 2015, 06:27:40)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
History
Date User Action Args
2022-04-11 14:58:14adminsetgithub: 67927
2015-03-22 16:10:36SilentGhostsetnosy: + lemburg, loewis
2015-03-22 15:39:39Saulius Žemaitaitissetmessages: + msg238915
2015-03-22 15:36:40Saulius Žemaitaitiscreate