[New-bugs-announce] [issue31752] Assertion failure in timedelta() in case of bad __divmod__
Serhiy Storchaka
report at bugs.python.org
Tue Oct 10 17:29:28 EDT 2017
New submission from Serhiy Storchaka <storchaka+cpython at 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 <report at bugs.python.org>
<https://bugs.python.org/issue31752>
_______________________________________
More information about the New-bugs-announce
mailing list