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.
Created on 2014年02月27日 11:56 by rene, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg212350 - (view) | Author: René Fleschenberg (rene) | Date: 2014年02月27日 11:56 | |
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).
|
|||
| msg212382 - (view) | Author: Ned Deily (ned.deily) * (Python committer) | Date: 2014年02月27日 20:27 | |
Thanks for the report. There was a lengthy discussion of this behavior a few years ago in Issue3067. 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: locale.setlocale(locale.LC_ALL, b'POSIX') |
|||
| msg212459 - (view) | Author: René Fleschenberg (rene) | Date: 2014年02月28日 16:59 | |
I see. Thanks for the information. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:59 | admin | set | github: 64992 |
| 2014年02月28日 16:59:01 | rene | set | messages: + msg212459 |
| 2014年02月27日 20:27:36 | ned.deily | set | status: open -> closed superseder: setlocale error message is confusing nosy: + ned.deily messages: + msg212382 resolution: duplicate stage: resolved |
| 2014年02月27日 11:56:07 | rene | create | |