python/cpython (original) (raw)

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))