[issue20793] locale.setlocale()

René Fleschenberg report at bugs.python.org
Thu Feb 27 12:56:07 CET 2014


New submission from René Fleschenberg:

locale.setlocale() does not work if you pass it a ``unicode`` object instead of a ``str`` (locale.py, line 576):

    ``if locale and type(locale) is not type(""):``

Maybe it would be better to do a check like this?

    ``if locale and not isinstance(locale, basestring):``

In particular, this can bite you if you use the ``unicode_literals`` future import, displaying a not-so-helpful error message ("ValueError: too many values to unpack" in _build_localename).

----------
messages: 212350
nosy: rene
priority: normal
severity: normal
status: open
title: locale.setlocale()
versions: Python 2.7

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


More information about the Python-bugs-list mailing list