Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
Closed
Description
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__
fromfractionsimportFractionfoo=Fraction(4,3)classOne:def__rpow__(self,other):returnotherbar=foo**One()print(bar)print(type(bar))
Expected Output
4/3<class 'fractions.Fraction'>
Actual Output:
1.3333333333333333<class 'float'>
Tested with Python 3.12.3
CPython versions tested on:
3.12
Operating systems tested on:
macOS
Linked PRs
- gh-119189: Add more tests for mixed Fraction arithmetic #119236
- gh-119189: Fix the fraction module so that __rpow__ works on arbitrary classes. #119242
- [3.13] gh-119189: Add more tests for mixed Fraction arithmetic (GH-119236) #119255
- [3.12] gh-119189: Add more tests for mixed Fraction arithmetic (GH-119236) #119256
- gh-119189: Add yet more tests for mixed Fraction arithmetic #119298
- [3.13] gh-119189: Add yet more tests for mixed Fraction arithmetic (GH-119298) #119346
- [3.12] gh-119189: Add yet more tests for mixed Fraction arithmetic (GH-119298) #119347
- [3.12] gh-119189: Fix the power operator for Fraction (GH-119242) #119835
- [3.13] gh-119189: Fix the power operator for Fraction (GH-119242) #119836