Author pitrou
Recipients pitrou
Date 2009-03-25.19:46:16
SpamBayes Score 1.97145e-06
Marked as misclassified No
Message-id <1238010378.87.0.1611631381.issue5562@psf.upfronthosting.co.za>
In-reply-to
Content
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))
'February'
>>> locale.setlocale(locale.LC_TIME, "fr_FR")
'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")
'fr_FR.UTF-8'
>>> time.strftime("%B", (2009,2,1,0,0,0,0,0,0))
'février'
History
Date User Action Args
2009-03-25 19:46:19pitrousetrecipients: + pitrou
2009-03-25 19:46:18pitrousetmessageid: <1238010378.87.0.1611631381.issue5562@psf.upfronthosting.co.za>
2009-03-25 19:46:17pitroulinkissue5562 messages
2009-03-25 19:46:16pitroucreate