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.

Author belopolsky
Recipients Arfrever, Martin.Morrison, Matthew.Earl, belopolsky, brett.cannon, docs@python, hynek, pconnell, pitrou, swalker, vstinner
Date 2013-10-24.17:08:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1382634503.77.0.716938480537.issue19376@psf.upfronthosting.co.za>
In-reply-to
Content
> what's the reason for accepting the time.strptime()
> version as a bug, but not datetime.datetime.strptime()?

In case of time.strptime(), we have an option of returning (1900, 2, 29, ..) which while not being a valid date, is a valid (time)tuple:

>>> time.mktime((1900, 2, 29, 0, 0, 0, 0, 0, 0))
-2203873200.0

The time module treats 1900-02-29 as 1900-03-01:

>>> time.mktime((1900, 3, 1, 0, 0, 0, 0, 0, 0))
-2203873200.0


Datetime is stricter than that:

>>> datetime(1900, 2, 29)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: day is out of range for month


There is no valid datetime value that can reasonably be returned from datetime.strptime('Feb 29', '%b %d').
History
Date User Action Args
2013-10-24 17:08:23belopolskysetrecipients: + belopolsky, brett.cannon, pitrou, vstinner, Arfrever, swalker, docs@python, hynek, Martin.Morrison, pconnell, Matthew.Earl
2013-10-24 17:08:23belopolskysetmessageid: <1382634503.77.0.716938480537.issue19376@psf.upfronthosting.co.za>
2013-10-24 17:08:23belopolskylinkissue19376 messages
2013-10-24 17:08:23belopolskycreate