STINNER Victor added the comment: 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. ---------- keywords: +patch nosy: +haypo title: Core dump / OverflowError for datetime.fromtimestamp with overly large timestamp in Ubuntu 12.04 -> datetime.fromtimestamp() does crash for very small or very big timestamp versions: +Python 3.7 Added file: http://bugs.python.org/file46124/datetime_check_args.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29100> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com