You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
Thanks for the report. There was a lengthy discussion of this behavior a few years ago in bpo-3067. At that time it was decided not to change this behavior for 2.7. I'm not sure if the __future__ "unicode_literals" was considered then, however you can work around it by using the b"" literal syntax:
Activity
rene commentedon Feb 27, 2014
locale.setlocale() does not work if you pass it a
unicodeobject instead of astr(locale.py, line 576):Maybe it would be better to do a check like this?
In particular, this can bite you if you use the
unicode_literalsfuture import, displaying a not-so-helpful error message ("ValueError: too many values to unpack" in _build_localename).ned-deily commentedon Feb 27, 2014
Thanks for the report. There was a lengthy discussion of this behavior a few years ago in bpo-3067. At that time it was decided not to change this behavior for 2.7. I'm not sure if the __future__ "unicode_literals" was considered then, however you can work around it by using the b"" literal syntax:
rene commentedon Feb 28, 2014
I see. Thanks for the information.