[New-bugs-announce] [issue23739] locale.setlocale checks locale name for string incorrectly

Saulius Žemaitaitis report at bugs.python.org
Sun Mar 22 16:36:40 CET 2015


New submission from Saulius Žemaitaitis:

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.

----------
components: Library (Lib)
messages: 238914
nosy: Saulius Žemaitaitis
priority: normal
severity: normal
status: open
title: locale.setlocale checks locale name for string incorrectly
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23739>
_______________________________________


More information about the New-bugs-announce mailing list