mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
Issue #27539: Fix unnormalised Fraction.__pow__ result for negative exponent and base. Thanks Vedran Čačić.
This commit is contained in:
parent
6afe85827c
commit
844796530a
4 changed files with 22 additions and 1 deletions
|
|
@ -484,10 +484,14 @@ class Fraction(numbers.Rational):
|
|||
return Fraction(a._numerator ** power,
|
||||
a._denominator ** power,
|
||||
_normalize=False)
|
||||
else:
|
||||
elif a._numerator >= 0:
|
||||
return Fraction(a._denominator ** -power,
|
||||
a._numerator ** -power,
|
||||
_normalize=False)
|
||||
else:
|
||||
return Fraction((-a._denominator) ** -power,
|
||||
(-a._numerator) ** -power,
|
||||
_normalize=False)
|
||||
else:
|
||||
# A fractional power will generally produce an
|
||||
# irrational number.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue