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.

Author pitrou
Recipients pitrou
Date 2009-03-25.19:46:16
SpamBayes Score 1.97145e-06
Marked as misclassified No
Message-id <>
Locale-based date formatting in py3k (using strftime) crashes when asked
to format a month name (or day, I assume) containing non-ASCII characters:

>>> import time
>>> import locale
>>> time.strftime("%B", (2009,2,1,0,0,0,0,0,0))
>>> locale.setlocale(locale.LC_TIME, "fr_FR")
>>> time.strftime("%B", (2009,2,1,0,0,0,0,0,0))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 1-3:
invalid data

It works if I specify the encoding explicitly in the locale name so as
to coincide with the encoding specified in the error message above (but
that's assuming the given encoding-specific locale *is* installed):

>>> locale.setlocale(locale.LC_TIME, "fr_FR.UTF-8")
>>> time.strftime("%B", (2009,2,1,0,0,0,0,0,0))
Date User Action Args
2009-03-25 19:46:19pitrousetrecipients: + pitrou
2009-03-25 19:46:18pitrousetmessageid: <>
2009-03-25 19:46:17pitroulinkissue5562 messages
2009-03-25 19:46:16pitroucreate