Author serhiy.storchaka
Recipients Oren Milman, belopolsky, serhiy.storchaka
Date 2017-10-10.21:29:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1507670968.8.0.213398074469.issue31752@psf.upfronthosting.co.za>
In-reply-to
Content
The following code causes an assertion error in timedelta constructor.

from datetime import timedelta

class BadInt(int):
    def __mul__(self, other):
        return Prod()

class Prod:
    def __radd__(self, other):
        return Sum()

class Sum:
    def __divmod__(self, other):
        return (0, -1)

timedelta(hours=BadInt(1))


Result:

python: /home/serhiy/py/cpython/Modules/_datetimemodule.c:1573: microseconds_to_delta_ex: Assertion `0 <= temp && temp < 1000000' failed.
Aborted (core dumped)
History
Date User Action Args
2017-10-10 21:29:28serhiy.storchakasetrecipients: + serhiy.storchaka, belopolsky, Oren Milman
2017-10-10 21:29:28serhiy.storchakasetmessageid: <1507670968.8.0.213398074469.issue31752@psf.upfronthosting.co.za>
2017-10-10 21:29:28serhiy.storchakalinkissue31752 messages
2017-10-10 21:29:28serhiy.storchakacreate