When using the ** operator with a Fraction as a base and an object that implements __rpow__ as an exponent the fraction gets wrongfully casted into a float before being passed to __rpow__
from fractions import Fraction
foo = Fraction(4, 3)
class One:
def __rpow__(self, other):
return other
bar = foo**One()
print(bar)
print(type(bar))
4/3
<class 'fractions.Fraction'>
1.3333333333333333
<class 'float'>
Bug report
Bug description:
When using the ** operator with a Fraction as a base and an object that implements __rpow__ as an exponent the fraction gets wrongfully casted into a float before being passed to __rpow__
Expected Output
Actual Output:
Tested with Python 3.12.3
CPython versions tested on:
3.12
Operating systems tested on:
macOS
Linked PRs