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 vstinner
Recipients Jordon Phillips, belopolsky, dstufft, vstinner
Date 2017-01-03.14:07:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1483452445.1.0.995238596031.issue29100@psf.upfronthosting.co.za>
In-reply-to
Content
Attached datetime_check_args.patch fixes the issue: move argument checks into time(), date() and datetime() constructors of the _datetime module.

The patch requires the fix of the issue #29140 (time_hash bug), otherwise unit tests fail.

This issue is a regression introduced the implementation of the PEP 495. In Python 3.5, datetime_from_timet_and_us() calls datetime constructor which checks argument. In Python 3.6, datetime_from_timet_and_us() calls directly new_datetime_ex2() which doesn't check arguments anymore.

datetime_check_args.patch makes the _datetime module generally safer, not only for the report bug, because new_datetime_ex2() can be called by different ways, for example from the C API: "PyDateTime_CAPI".

The bug always shows a major lack of unit test in datetime.datetime.fromtimestamp() on dates out of the 0001-01-01 .. 9999-12-31 range. In Python 3.6, datetime.fromtimestamp() can create invalid datetime object greater than datetime.max!

$ python3.6 -c 'import datetime; print(datetime.datetime.fromtimestamp(2**38))'
10680-07-14 08:09:04

TODO: add unit tests.
History
Date User Action Args
2017-01-03 14:07:25vstinnersetrecipients: + vstinner, belopolsky, dstufft, Jordon Phillips
2017-01-03 14:07:25vstinnersetmessageid: <1483452445.1.0.995238596031.issue29100@psf.upfronthosting.co.za>
2017-01-03 14:07:25vstinnerlinkissue29100 messages
2017-01-03 14:07:24vstinnercreate