Issue2285

classification
Title: _strptime broken with non-English locales
Type: Severity: normal
Components: Versions: Jython 2.7
Milestone:
process
Status: open Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: Arfrever, alex.gronholm, pekka.klarck, zyasoft
Priority: Keywords:

Created on 2015-03-10.12:10:42 by Arfrever, last changed 2017-01-30.08:16:17 by pekka.klarck.

Messages
msg9604 (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) Date: 2015-03-10.12:10:42
$ LC_ALL="pl_PL.UTF-8" python2.7 -c "import time; print(time.strptime('Thu, 01-Jan-1970', '%a, %d-%b-%Y'))"
time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=-1)
$ LC_ALL="en_US.UTF-8" jython2.7 -c "import time; print(time.strptime('Thu, 01-Jan-1970', '%a, %d-%b-%Y'))"
time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=-1)
$ LC_ALL="pl_PL.UTF-8" jython2.7 -c "import time; print(time.strptime('Thu, 01-Jan-1970', '%a, %d-%b-%Y'))"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/share/jython-2.7/Lib/_strptime.py", line 467, in _strptime_time
    return _strptime(data_string, format)[0]
  File "/usr/share/jython-2.7/Lib/_strptime.py", line 324, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data u'Thu, 01-Jan-1970' does not match format u'%a, %d-%b-%Y'
$
msg9665 (view) Author: Jim Baker (zyasoft) Date: 2015-03-16.20:43:53
Jython currently only implements the C locale fallback in the pure Python locale module. This should be fixed, but it's too late for 2.7.0
msg9822 (view) Author: Alex Grönholm (alex.gronholm) Date: 2015-04-13.23:14:56
I'm getting a UnicodeDecodeError instead.
msg11043 (view) Author: Pekka Klärck (pekka.klarck) Date: 2017-01-30.08:13:33
Unicode error Alex sees is also reported as issue 2503.
msg11044 (view) Author: Pekka Klärck (pekka.klarck) Date: 2017-01-30.08:16:17
The biggest problem here seems to be the locale dependent `%b` directive. At least in our usage `strptime` has worked fine otherwise.

(Second attempt to link to issue #2503.)
History
Date User Action Args
2017-01-30 08:16:17pekka.klarcksetmessages: + msg11044
2017-01-30 08:13:33pekka.klarcksetnosy: + pekka.klarck
messages: + msg11043
2015-04-13 23:14:56alex.gronholmsetnosy: + alex.gronholm
messages: + msg9822
2015-03-16 20:43:53zyasoftsetresolution: accepted
messages: + msg9665
nosy: + zyasoft
2015-03-10 12:10:42Arfrevercreate