changeset: 102857:ea495a5ded9b user: Mark Dickinson date: Tue Aug 23 16:16:52 2016 +0100 files: Lib/fractions.py Lib/test/test_fractions.py Misc/NEWS description: Issue #27832: Make _normalize parameter to Fraction.__init__ keyword-only. diff -r c1a698edfa1b -r ea495a5ded9b Lib/fractions.py --- a/Lib/fractions.py Tue Aug 23 16:22:35 2016 +0200 +++ b/Lib/fractions.py Tue Aug 23 16:16:52 2016 +0100 @@ -81,7 +81,7 @@ __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 -r c1a698edfa1b -r ea495a5ded9b Lib/test/test_fractions.py --- a/Lib/test/test_fractions.py Tue Aug 23 16:22:35 2016 +0200 +++ b/Lib/test/test_fractions.py Tue Aug 23 16:16:52 2016 +0100 @@ -150,6 +150,7 @@ 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 -r c1a698edfa1b -r ea495a5ded9b Misc/NEWS --- a/Misc/NEWS Tue Aug 23 16:22:35 2016 +0200 +++ b/Misc/NEWS Tue Aug 23 16:16:52 2016 +0100 @@ -46,6 +46,9 @@ 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.