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 twouters
Recipients gregory.p.smith, serhiy.storchaka, twouters
Date 2018-10-18.17:37:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The fix for issue #31752 (changeset 5ef883b096895a84123760859f0f34ad37bf2277 for 2.7, as I ran into this while upgrading to 2.7.15) includes assertions that are easily triggered from user code:

>>> import datetime, numpy
>>> datetime.timedelta(seconds=numpy.int64(0))
python: .../Modules/datetimemodule.c:1859: accum: Assertion `_PyAnyInt_CheckExact(prod)' failed.
Aborted (core dumped)

The code asserts that the product of a known type and an unknown type is a known type, which is not a valid assumption. Pure-python reproducer (requires a build with assertions enabled, like a --with-pydebug build).

>>> import datetime
>>> class C(int):
...     def __rmul__(self, other):
...         return self
>>> datetime.timedelta(seconds=C())
python: .../Modules/datetimemodule.c:1859: accum: Assertion `_PyAnyInt_CheckExact(prod)' failed.
Aborted (core dumped)

(It fails in a similar way in at least Python 3.7, and since the fix was backported I'm going to assume 3.6 as well.)

Please do not use assertions for things that aren't guaranteed by the code making the assertions. These should either not be assertions, or the input types should be validated beforehand. I do not know why these assertions are being made in the first place. What do they guard against?
Date User Action Args
2018-10-18 17:37:14twouterssetrecipients: + twouters, gregory.p.smith, serhiy.storchaka
2018-10-18 17:37:14twouterssetmessageid: <>
2018-10-18 17:37:14twouterslinkissue35021 messages
2018-10-18 17:37:14twouterscreate