summaryrefslogtreecommitdiffstats
path: root/Lib/fractions.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2016-08-22 09:56:06 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2016-08-22 09:56:06 (GMT)
commit0add84b9b855c10e9c6434286c2b1157a754a39f (patch)
treeb17328d4cb3258611a6617e0a14ad4c98ff03431 /Lib/fractions.py
parentdc65c685249758c576f3fd915f7f913cdc0a0d2b (diff)
parent844796530a21f2a8689f2b9e01035d4a64a95275 (diff)
downloadcpython-0add84b9b855c10e9c6434286c2b1157a754a39f.zip
cpython-0add84b9b855c10e9c6434286c2b1157a754a39f.tar.gz
cpython-0add84b9b855c10e9c6434286c2b1157a754a39f.tar.bz2
Issue #27539: Merge from 3.5.
Diffstat (limited to 'Lib/fractions.py')
-rw-r--r--Lib/fractions.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/fractions.py b/Lib/fractions.py
index 64d746b..a712052 100644
--- a/Lib/fractions.py
+++ b/Lib/fractions.py
@@ -460,10 +460,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.