Message201108
| Author |
Matthew.Earl |
| Recipients |
Arfrever, Martin.Morrison, Matthew.Earl, belopolsky, hynek, pconnell, pitrou, swalker, vstinner |
| Date |
2013年10月24日.10:02:17 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1382608937.44.0.992947795428.issue19376@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|