New submission from Serhiy Storchaka <storchaka+cpyt...@gmail.com>:

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)

----------
components: Extension Modules
messages: 304083
nosy: Oren Milman, belopolsky, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Assertion failure in timedelta() in case of bad __divmod__
type: crash
versions: Python 2.7, Python 3.6, Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31752>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to