homepage

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.

classification
Title: ValueError: time data does not match format
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: dellair.jie, vstinner
Priority: normal Keywords:

Created on 2014年01月07日 14:45 by dellair.jie, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Messages (9)
msg207542 - (view) Author: dellair jie (dellair.jie) Date: 2014年01月07日 14:45
Hello,
We are using Python 3.3.2 for HPUX11.31.
The following error happens only on HPUX, works on SunOS, RHEL, AIX.
python
Python 3.3.2 (default, Dec 9 2013, 14:04:25) [C] on hp-ux11
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.strptime ("10-Dec-13.20:07:49", "%d-%b-%y.%H:%M:%S")
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/python/lib/python3.3/_strptime.py", line 500, in _strptime_datetime
 tt, fraction = _strptime(data_string, format)
 File "/python/lib/python3.3/_strptime.py", line 337, in _strptime
 (data_string, format))
ValueError: time data '10-Dec-13.20:07:49' does not match format '%d-%b-%y.%H:%M:%S'
It looks like a bug. Could you please shed some lights?
Thanks in advance,
Br,
Li
msg207545 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014年01月07日 15:00
Try to isolate which field fails. Example:
>>> import time
>>> time.strptime ("10-Dec-13.20:07:49", "%d-%b-%y.%H:%M:%S")
time.struct_time(tm_year=2013, tm_mon=12, tm_mday=10, tm_hour=20, tm_min=7, tm_sec=49, tm_wday=1, tm_yday=344, tm_isdst=-1)
>>> time.strptime ("10-Dec-13", "%d-%b-%y")
time.struct_time(tm_year=2013, tm_mon=12, tm_mday=10, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=1, tm_yday=344, tm_isdst=-1)
>>> time.strptime ("10-Dec", "%d-%b")
time.struct_time(tm_year=1900, tm_mon=12, tm_mday=10, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=0, tm_yday=344, tm_isdst=-1)
>>> time.strptime ("Dec", "%b")
time.struct_time(tm_year=1900, tm_mon=12, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=5, tm_yday=335, tm_isdst=-1)
msg207548 - (view) Author: dellair jie (dellair.jie) Date: 2014年01月07日 15:42
Victor,
Thanks for the comment.
Isolated, the error happens at:
>>> import time
>>> time.strptime ("Dec", "%b")
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/python/lib/python3.3/_strptime.py", line 494, in _strptime_time
 tt = _strptime(data_string, format)[0]
 File "/python/lib/python3.3/_strptime.py", line 340, in _strptime
 data_string[found.end():])
ValueError: unconverted data remains: Dec
msg207549 - (view) Author: dellair jie (dellair.jie) Date: 2014年01月07日 15:43
The output of command:
$ date +'%b'
Jan
$ uname -a
HP-UX test5 B.11.31 U ia64 4201936010 unlimited-user license
msg207551 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014年01月07日 16:00
> >>> time.strptime ("Dec", "%b")
> ValueError: unconverted data remains: Dec
Ok, so what is the name of the December month?
>>> import time
>>> time.strftime("%b", time.gmtime(1387036705))
'Dec'
msg207553 - (view) Author: dellair jie (dellair.jie) Date: 2014年01月07日 16:22
We get an empty string for the name. :)
>>> time.strftime("%b", time.gmtime(1387036705))
''
msg207557 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014年01月07日 16:44
> We get an empty string for the name. :)
Ok, it's maybe time to upgrade to Linux :-) (How old is HPUX? I didn't know that it's still in use.)
I don't see how Python could workaround the issue if strftime("%b") doesn't work. An option would be to reimplemenet strftime() (in Python?), see #3173.
msg207572 - (view) Author: dellair jie (dellair.jie) Date: 2014年01月07日 17:53
Victor,
HPUX 11.31 was first released in 2007, we keep upgrading and the latest update is in 2013. ^_^
A workaround sounds fine. By re-implementing strftime(), do you mean to patch it from: http://bugs.python.org/issue1777412? 
msg215049 - (view) Author: dellair jie (dellair.jie) Date: 2014年03月28日 15:14
We've found a workaround to handle the timestr manually.
Thanks,
History
Date User Action Args
2022年04月11日 14:57:56adminsetgithub: 64362
2014年03月28日 15:14:48dellair.jiesetstatus: open -> closed

messages: + msg215049
2014年01月07日 17:53:16dellair.jiesetmessages: + msg207572
2014年01月07日 16:44:57vstinnersetmessages: + msg207557
2014年01月07日 16:22:50dellair.jiesetmessages: + msg207553
2014年01月07日 16:00:11vstinnersetmessages: + msg207551
2014年01月07日 15:43:42dellair.jiesetmessages: + msg207549
2014年01月07日 15:42:44dellair.jiesetmessages: + msg207548
2014年01月07日 15:00:24vstinnersetnosy: + vstinner
messages: + msg207545
2014年01月07日 14:45:13dellair.jiecreate

AltStyle によって変換されたページ (->オリジナル) /