Message84163
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' |
|
Date |
User |
Action |
Args |
2009-03-25 19:46:19 | pitrou | set | recipients:
+ pitrou |
2009-03-25 19:46:18 | pitrou | set | messageid: <1238010378.87.0.1611631381.issue5562@psf.upfronthosting.co.za> |
2009-03-25 19:46:17 | pitrou | link | issue5562 messages |
2009-03-25 19:46:16 | pitrou | create | |
|