Skip to content

Conversation

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Oct 10, 2017

Bad remainder in divmod() in intermediate calculations caused an assertion failure.

https://bugs.python.org/issue31752

…stom integers.

Bad remainder in divmod() in intermediate calculations caused an assertion failure.
Copy link
Member

@vstinner vstinner left a 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:
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok.

Copy link
Member

@terryjreedy terryjreedy left a 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.

@bedevere-bot
Copy link

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 I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@serhiy-storchaka
Copy link
Member Author

What is f:/python/mypy/tem.py? I just have installed mypy, but don't see the file tem.py there. Tests are passed on Windows to me.

@terryjreedy
Copy link
Member

mypy is my personal directory of miscellaneous .py files, which a have had for at least a decade. I guess I should rename it. tem.py should have been the code in the initial post with a print added. I should have been clearer.

Without the patch, with a fresh build,
python -m test test_datetime passes (and ditto for whole suite, without test_datetime added)
python -m unittest test.test_datetime passes
python -m test.test_datetime crashes in test_strftime with 'Debug assertion failed' in line 1184 of min\kernal\crts\ucrt\src\appcrt\time\wcsftime.cpp. I don't know what to make of this.

I will apply the patch again, re-build, and try to reproduce what I think I did before, keep better notes, and report again.

@terryjreedy terryjreedy dismissed their stale review October 22, 2017 18:09

I cannot reproduce the negative result.

@terryjreedy
Copy link
Member

This time, printing the time delta of 1 in your opening code works instead of crashing.
python -m test.test_datetime still crashes, but that must be a different issue.

@serhiy-storchaka serhiy-storchaka merged commit 4ffd465 into python:master Oct 23, 2017
@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-4086 is a backport of this pull request to the 3.6 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 23, 2017
…stom integers. (pythonGH-3947)

Bad remainder in divmod() in intermediate calculations caused an assertion failure.
(cherry picked from commit 4ffd465)
@miss-islington
Copy link
Contributor

Sorry, @serhiy-storchaka, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 4ffd4653a7ec9c97775472276cf5e159e2366bb2 2.7

serhiy-storchaka pushed a commit that referenced this pull request Oct 23, 2017
…stom integers. (GH-3947) (#4086)

Bad remainder in divmod() in intermediate calculations caused an assertion failure.
(cherry picked from commit 4ffd465)
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Oct 23, 2017
…ith custom integers. (pythonGH-3947)

Bad remainder in divmod() in intermediate calculations caused an assertion failure..
(cherry picked from commit 4ffd465)
serhiy-storchaka added a commit that referenced this pull request Oct 23, 2017
…ith custom integers. (GH-3947) (#4088)

Bad remainder in divmod() in intermediate calculations caused an assertion failure..
(cherry picked from commit 4ffd465)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants