Skip to content
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-39350: Fix fractions for int subclasses #18375

Merged
merged 1 commit into from
Feb 7, 2020
Merged

bpo-39350: Fix fractions for int subclasses #18375

merged 1 commit into from
Feb 7, 2020

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Feb 6, 2020

Fix regression in fractions.Fraction if the numerator and/or the
denominator is an int subclass.

https://bugs.python.org/issue39350

@vstinner
Copy link
Member Author

vstinner commented Feb 6, 2020

That's an alternative fix for https://bugs.python.org/issue39350

See PR #18309 to discussion (the other proposed fix).

@vstinner
Copy link
Member Author

vstinner commented Feb 6, 2020

I tested manually that fractions.Fraction works again with numpy.int64: it works as expected.

See: https://bugs.python.org/issue39350#msg361483

Copy link
Member

@mdickinson mdickinson left a comment

Choose a reason for hiding this comment

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

The change LGTM, but we should make it clear in the Misc/NEWS entry that there's an actual behaviour change here from 3.8: it's not simply a case of a regression being introduced and then fixed.

@vstinner
Copy link
Member Author

vstinner commented Feb 6, 2020

@mdickinson: I completed the documentation, would you mind to review it?

@mdickinson: You approved my PR. Does it mean that you are ok to always divide the numerator and denominator with an int, which is a Python 3.9 incompatible change? I'm fine with that, since I propose the change. But I prefer to confirm with you, since you proposed PR #18309 :-)

@mdickinson
Copy link
Member

Still LGTM, especially with the versionchanged update. Thank you!

Does it mean that you are ok to always divide the numerator and denominator with an int, which is a Python 3.9 incompatible change?

@vstinner Yes, I'm personally fine with that change; I don't know how other interested parties might feel about it, and there seems a risk that people won't even notice that there's a behaviour change proposed and implemented without a dedicated b.p.o. issue. OTOH, I think it ought to be relatively uncontroversial, so perhaps we don't need that issue and discussion.

Fix regression in fractions.Fraction if the numerator and/or the
denominator is an int subclass.
@vstinner
Copy link
Member Author

vstinner commented Feb 7, 2020

@vstinner Yes, I'm personally fine with that change; I don't know how other interested parties might feel about it, and there seems a risk that people won't even notice that there's a behaviour change proposed and implemented without a dedicated b.p.o. issue. OTOH, I think it ought to be relatively uncontroversial, so perhaps we don't need that issue and discussion.

I really liked the discussion :-) It was required to discuss how other types are handled. At the beginning, I didn't think about types other than int. At least, my PR now adds a test for an int subclass :-)

@vstinner vstinner merged commit dc7a50d into python:master Feb 7, 2020
@vstinner vstinner deleted the fractions_int_subclass branch February 7, 2020 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants