Issue 31752: Assertion failure in timedelta() in case of bad divmod (original) (raw)

Created on 2017-10-10 21:29 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3947 merged serhiy.storchaka,2017-10-10 21:49
PR 4086 merged python-dev,2017-10-23 14:12
PR 4088 merged serhiy.storchaka,2017-10-23 15:50
PR 9958 serhiy.storchaka,2018-10-19 11:34
PR 10039 merged serhiy.storchaka,2018-10-22 19:54
PR 10040 open serhiy.storchaka,2018-10-22 20:09
PR 10614 merged miss-islington,2018-11-20 18:41
PR 10615 merged miss-islington,2018-11-20 18:41
PR 10617 merged serhiy.storchaka,2018-11-20 19:15
Messages (12)
msg304083 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-10 21:29
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)
msg304131 - (view) Author: Louie Lu (louielu) * Date: 2017-10-11 13:22
I got a different result in latest commit: eeb5ffd54e5 ➜ cpython git:(master) ✗ ./python test.py Traceback (most recent call last): File "test.py", line 15, in timedelta(hours=BadInt(1)) SystemError: <class 'datetime.timedelta'> returned NULL without setting an error Do I miss some configure, I'm using ./configure --with-debug
msg304351 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-10-13 19:32
On Win10, installed 3.5.4, 3.6.3, 3.7.1a1 all raise SystemError. 3.6 and 3.7 repository debug builds raise AssertionError and Windows crash box. After the patch, a silent crash.
msg304751 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-22 14:27
Unpatched Python should crash in debug build and can raise SystemError in release build. I can't reproduce a crash on Windows after the patch.
msg304808 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-23 14:12
New changeset 4ffd4653a7ec9c97775472276cf5e159e2366bb2 by Serhiy Storchaka in branch 'master': bpo-31752: Fix possible crash in timedelta constructor called with custom integers. (#3947) https://github.com/python/cpython/commit/4ffd4653a7ec9c97775472276cf5e159e2366bb2
msg304810 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-23 15:20
New changeset 6e45d7b90accbbdfef353c41ab0a78a3e4742803 by Serhiy Storchaka (Miss Islington (bot)) in branch '3.6': bpo-31752: Fix possible crash in timedelta constructor called with custom integers. (GH-3947) (#4086) https://github.com/python/cpython/commit/6e45d7b90accbbdfef353c41ab0a78a3e4742803
msg304822 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-23 16:57
New changeset 5ef883b096895a84123760859f0f34ad37bf2277 by Serhiy Storchaka in branch '2.7': [2.7] bpo-31752: Fix possible crash in timedelta constructor called with custom integers. (GH-3947) (#4088) https://github.com/python/cpython/commit/5ef883b096895a84123760859f0f34ad37bf2277
msg327990 - (view) Author: Thomas Wouters (twouters) * (Python committer) Date: 2018-10-18 17:37
This patch includes assertions that are easily triggered from user code: https://bugs.python.org/issue35021
msg330143 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-11-20 18:41
New changeset 3ec0f495163da3b7a15deb2805cec48aed432f58 by Serhiy Storchaka in branch 'master': bpo-35021: Fix assertion failures in _datetimemodule.c. (GH-10039) https://github.com/python/cpython/commit/3ec0f495163da3b7a15deb2805cec48aed432f58
msg330146 - (view) Author: miss-islington (miss-islington) Date: 2018-11-20 18:59
New changeset d57ab8ac182d15558118523ad1b11b029e105c46 by Miss Islington (bot) in branch '3.7': bpo-35021: Fix assertion failures in _datetimemodule.c. (GH-10039) https://github.com/python/cpython/commit/d57ab8ac182d15558118523ad1b11b029e105c46
msg330148 - (view) Author: miss-islington (miss-islington) Date: 2018-11-20 19:02
New changeset 7a0d964afb41bde846771c81ba746238339cdd8c by Miss Islington (bot) in branch '3.6': bpo-35021: Fix assertion failures in _datetimemodule.c. (GH-10039) https://github.com/python/cpython/commit/7a0d964afb41bde846771c81ba746238339cdd8c
msg330151 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-11-20 19:56
New changeset 40fdf471931f029ea07e6190f0fe116e0735661b by Serhiy Storchaka in branch '2.7': [2.7] bpo-35021: Fix assertion failures in _datetimemodule.c. (GH-10039) (GH-10617) https://github.com/python/cpython/commit/40fdf471931f029ea07e6190f0fe116e0735661b
History
Date User Action Args
2022-04-11 14:58:53 admin set github: 75933
2018-11-20 19:56:41 serhiy.storchaka set messages: +
2018-11-20 19:15:48 serhiy.storchaka set pull_requests: + <pull%5Frequest9864>
2018-11-20 19:02:53 miss-islington set messages: +
2018-11-20 18:59:14 miss-islington set nosy: + miss-islingtonmessages: +
2018-11-20 18:41:38 miss-islington set pull_requests: + <pull%5Frequest9861>
2018-11-20 18:41:32 miss-islington set pull_requests: + <pull%5Frequest9859>
2018-11-20 18:41:12 serhiy.storchaka set messages: +
2018-10-22 20:09:05 serhiy.storchaka set pull_requests: + <pull%5Frequest9379>
2018-10-22 19:54:58 serhiy.storchaka set pull_requests: + <pull%5Frequest9377>
2018-10-19 11:34:58 serhiy.storchaka set pull_requests: + <pull%5Frequest9311>
2018-10-18 17:37:34 twouters set nosy: + twoutersmessages: +
2017-10-23 16:57:20 serhiy.storchaka set status: open -> closedresolution: fixedstage: patch review -> resolved
2017-10-23 16:57:06 serhiy.storchaka set messages: +
2017-10-23 15:50:28 serhiy.storchaka set pull_requests: + <pull%5Frequest4058>
2017-10-23 15:20:16 serhiy.storchaka set messages: +
2017-10-23 14:12:38 python-dev set pull_requests: + <pull%5Frequest4056>
2017-10-23 14:12:34 serhiy.storchaka set messages: +
2017-10-22 14:27:41 serhiy.storchaka set messages: +
2017-10-13 19:32:13 terry.reedy set nosy: + terry.reedymessages: +
2017-10-11 13:22:30 louielu set nosy: + louielumessages: +
2017-10-10 21:49:17 serhiy.storchaka set keywords: + patchpull_requests: + <pull%5Frequest3922>
2017-10-10 21:29:28 serhiy.storchaka create