-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-31752: Fix possible crash in timedelta constructor called with custom integers. #3947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-31752: Fix possible crash in timedelta constructor called with custom integers. #3947
Conversation
…stom integers. Bad remainder in divmod() in intermediate calculations caused an assertion failure.
vstinner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, except of a minor comment.
| def __mul__(self, other): | ||
| return Prod() | ||
|
|
||
| class Prod: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe inherit from int as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it shouldn't be inherited from int, otherwise __radd__ would not be called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok.
terryjreedy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Win10, this changes a noisy crash, with crash box and printed message, to a silent crash
f:\dev\3x>python f:/python/mypy/tem.py
Running Debug|Win32 interpreter...
f:\dev\3x> # printed immediately after above
which to me is worse. I verified that datetimetester.py has the new test_issue31752.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
What is |
|
Without the patch, with a fresh build, I will apply the patch again, re-build, and try to reproduce what I think I did before, keep better notes, and report again. |
I cannot reproduce the negative result.
|
This time, printing the time delta of 1 in your opening code works instead of crashing. |
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6. |
|
GH-4086 is a backport of this pull request to the 3.6 branch. |
…stom integers. (pythonGH-3947) Bad remainder in divmod() in intermediate calculations caused an assertion failure. (cherry picked from commit 4ffd465)
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
…ith custom integers. (pythonGH-3947) Bad remainder in divmod() in intermediate calculations caused an assertion failure.. (cherry picked from commit 4ffd465)
Bad remainder in divmod() in intermediate calculations caused an assertion failure.
https://bugs.python.org/issue31752