New submission from Matthew Earl: 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. ---------- components: Library (Lib) messages: 201108 nosy: Arfrever, Martin.Morrison, Matthew.Earl, belopolsky, haypo, hynek, pconnell, pitrou, swalker priority: normal severity: normal status: open title: datetime.datetime.strptime without a year fails on Feb 29 type: behavior versions: Python 2.7, Python 3.2, Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19376> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com