summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2016-08-23 15:16:52 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2016-08-23 15:16:52 (GMT)
commit7caf908c64a0d6d8c875e7403f22992227be47f2 (patch)
tree68d8ac2ed42eec79ba69423e9f35324fef52a945
parentf4d28d43857295cab4dc82a2bc50f5e8c90123ef (diff)
downloadcpython-7caf908c64a0d6d8c875e7403f22992227be47f2.zip
cpython-7caf908c64a0d6d8c875e7403f22992227be47f2.tar.gz
cpython-7caf908c64a0d6d8c875e7403f22992227be47f2.tar.bz2
Issue #27832: Make _normalize parameter to Fraction.__init__ keyword-only.
-rw-r--r--Lib/fractions.py2
-rw-r--r--Lib/test/test_fractions.py1
-rw-r--r--Misc/NEWS3
3 files changed, 5 insertions, 1 deletions
diff --git a/Lib/fractions.py b/Lib/fractions.py
index a712052..8330202 100644
--- a/Lib/fractions.py
+++ b/Lib/fractions.py
@@ -81,7 +81,7 @@ class Fraction(numbers.Rational):
__slots__ = ('_numerator', '_denominator')
# We're immutable, so use __new__ not __init__
- def __new__(cls, numerator=0, denominator=None, _normalize=True):
+ def __new__(cls, numerator=0, denominator=None, *, _normalize=True):
"""Constructs a Rational.
Takes a string like '3/2' or '1.5', another Rational instance, a
diff --git a/Lib/test/test_fractions.py b/Lib/test/test_fractions.py
index 664c735..7905c36 100644
--- a/Lib/test/test_fractions.py
+++ b/Lib/test/test_fractions.py
@@ -150,6 +150,7 @@ class FractionTest(unittest.TestCase):
self.assertRaises(TypeError, F, "3/2", 3)
self.assertRaises(TypeError, F, 3, 0j)
self.assertRaises(TypeError, F, 3, 1j)
+ self.assertRaises(TypeError, F, 1, 2, 3)
@requires_IEEE_754
def testInitFromFloat(self):
diff --git a/Misc/NEWS b/Misc/NEWS
index dfe33fe..6f31ec0 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -46,6 +46,9 @@ Core and Builtins
Library
-------
+- Issue #27832: Make ``_normalize`` parameter to ``Fraction`` constuctor
+ keyword-only, so that ``Fraction(2, 3, 4)`` now raises ``TypeError``.
+
- Issue #27539: Fix unnormalised ``Fraction.__pow__`` result in the case
of negative exponent and negative base.