Message201108
datetime.datetime.strptime() without a year fails on Feb 29 with:
>>> datetime.datetime.strptime("Feb 29", "%b %d")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/auto/ensoft-sjc/thirdparty/lib/python3.3/_strptime.py", line 511, in _strptime_datetime
return cls(*args)
ValueError: day is out of range for month
This is because without a year specified the year is assumed to be 1900, which is not a leap year. The underlying _strptime._strptime() function has some munging such that it doesn't itself fail (see #14157):
>>> _strptime._strptime("Feb 29", "%b %d")
((1900, 2, 29, 0, 0, 0, 0, 60, -1, None, None), 0)
...however datetime.datetime.__init__() is called with this tuple as *args, causing the validation failure. |
|
Date |
User |
Action |
Args |
2013-10-24 10:02:17 | Matthew.Earl | set | recipients:
+ Matthew.Earl, belopolsky, pitrou, vstinner, Arfrever, swalker, hynek, Martin.Morrison, pconnell |
2013-10-24 10:02:17 | Matthew.Earl | set | messageid: <1382608937.44.0.992947795428.issue19376@psf.upfronthosting.co.za> |
2013-10-24 10:02:17 | Matthew.Earl | link | issue19376 messages |
2013-10-24 10:02:17 | Matthew.Earl | create | |
|