gh-119189: Fix the fraction module so that __rpow__ works on arbitrary classes. - #119242
Conversation
The fraction module implicitly casted float if __rpow__ was implemented in your class when raising a fraction to a power. Now it isn't done but will raise an exception if __rpow__ isn't implemented.
7d628e3 to
1de7a44
Compare
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Please update tests.
Also, I think that the text of the NEWS entry should be rewritten. It's hard to understand right now, I'm not even sure if it's correct at all.
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Please update tests and rewrite the NEWS entry.
|
Okay I will update tests. |
|
I have made the requested changes; please review again. |
|
Thanks for making the requested changes! @serhiy-storchaka: please review the changes made to this pull request. |
|
Tests are still failing. You have to make them pass. |
|
I have made the requested changes; please review again. |
|
Thanks for making the requested changes! @serhiy-storchaka: please review the changes made to this pull request. |
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Added accidental removal of comment
|
I have made the requested changes; please review again. |
|
Thanks for making the requested changes! @serhiy-storchaka: please review the changes made to this pull request. |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
LGTM. Thank you for your contribution @zitterbewegung.
|
Thanks @zitterbewegung for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
|
Thanks @zitterbewegung for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
When using the ** operator or pow() with Fraction as the base and an exponent that is not rational, a float, or a complex, the fraction is no longer converted to a float. (cherry picked from commit b9965ef) Co-authored-by: Joshua Herman <30265+zitterbewegung@users.noreply.github.com>
When using the ** operator or pow() with Fraction as the base and an exponent that is not rational, a float, or a complex, the fraction is no longer converted to a float. (cherry picked from commit b9965ef) Co-authored-by: Joshua Herman <30265+zitterbewegung@users.noreply.github.com>
|
GH-119835 is a backport of this pull request to the 3.12 branch. |
|
GH-119836 is a backport of this pull request to the 3.13 branch. |
When using the ** operator or pow() with Fraction as the base and an exponent that is not rational, a float, or a complex, the fraction is no longer converted to a float.
When using the ** operator or pow() with Fraction as the base and an exponent that is not rational, a float, or a complex, the fraction is no longer converted to a float.

gh-119189: Fix the fraction module so that rpow works on arbitrary classes.