Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0add84b9
Commit
0add84b9
authored
Aug 22, 2016
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Plain Diff
Issue #27539: Merge from 3.5.
parents
dc65c685
84479653
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
1 deletion
+22
-1
Lib/fractions.py
Lib/fractions.py
+5
-1
Lib/test/test_fractions.py
Lib/test/test_fractions.py
+13
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/fractions.py
View file @
0add84b9
...
...
@@ -460,10 +460,14 @@ class Fraction(numbers.Rational):
return
Fraction
(
a
.
_numerator
**
power
,
a
.
_denominator
**
power
,
_normalize
=
False
)
el
se
:
el
if
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.
...
...
Lib/test/test_fractions.py
View file @
0add84b9
...
...
@@ -356,6 +356,19 @@ class FractionTest(unittest.TestCase):
z
=
pow
(
F
(
-
1
),
F
(
1
,
2
))
self
.
assertAlmostEqual
(
z
.
real
,
0
)
self
.
assertEqual
(
z
.
imag
,
1
)
# Regression test for #27539.
p
=
F
(
-
1
,
2
)
**
0
self
.
assertEqual
(
p
,
F
(
1
,
1
))
self
.
assertEqual
(
p
.
numerator
,
1
)
self
.
assertEqual
(
p
.
denominator
,
1
)
p
=
F
(
-
1
,
2
)
**
-
1
self
.
assertEqual
(
p
,
F
(
-
2
,
1
))
self
.
assertEqual
(
p
.
numerator
,
-
2
)
self
.
assertEqual
(
p
.
denominator
,
1
)
p
=
F
(
-
1
,
2
)
**
-
2
self
.
assertEqual
(
p
,
F
(
4
,
1
))
self
.
assertEqual
(
p
.
numerator
,
4
)
self
.
assertEqual
(
p
.
denominator
,
1
)
def
testMixedArithmetic
(
self
):
self
.
assertTypedEquals
(
F
(
11
,
10
),
F
(
1
,
10
)
+
1
)
...
...
Misc/ACKS
View file @
0add84b9
...
...
@@ -218,6 +218,7 @@ Katherine Busch
Ralph Butler
Laurent De Buyst
Zach Byrne
Vedran Čačić
Nicolas Cadou
Jp Calderone
Arnaud Calmettes
...
...
Misc/NEWS
View file @
0add84b9
...
...
@@ -38,6 +38,9 @@ Core and Builtins
Library
-------
- Issue #27539: Fix unnormalised ``Fraction.__pow__`` result in the case
of negative exponent and negative base.
- Issue #21718: cursor.description is now available for queries using CTEs.
- Issue #27819: In distutils sdists, simply produce the "gztar" (gzipped tar
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment