Author veky
Recipients mark.dickinson, rhettinger, terry.reedy, veky
Date 2016-08-11.18:41:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1470940903.38.0.177897714522.issue27539@psf.upfronthosting.co.za>
In-reply-to
Content
Here is the code for the patch:

84c84
<     def __new__(cls, numerator=0, denominator=None, _normalize=True):
---
>     def __new__(cls, numerator=0, denominator=None, *, _normalize=True):
459,466c459,466
<                 if power >= 0:
<                     return Fraction(a._numerator ** power,
<                                     a._denominator ** power,
<                                     _normalize=False)
<                 else:
<                     return Fraction(a._denominator ** -power,
<                                     a._numerator ** -power,
<                                     _normalize=False)
---
>                 num = a._numerator
>                 den = a._denominator
>                 if power < 0:
>                     num, den, power = den, num, -power
>                     if den < 0:
>                         num = -num
>                         den = -den
>                 return Fraction(num ** power, den ** power, _normalize=False)

I tried to add the test to test_fractions.py, but unfortunately unittest reports 3 unrelated failures due to mismatch in error messages (why does it check exact messages of exceptions anyway?). But it should just be adding

        self.assertTypedEquals(F(-1, 2), F(-2) ** -1)

after line 408.

_Please_, can this go in before 15th?
History
Date User Action Args
2016-08-11 18:41:43vekysetrecipients: + veky, rhettinger, terry.reedy, mark.dickinson
2016-08-11 18:41:43vekysetmessageid: <1470940903.38.0.177897714522.issue27539@psf.upfronthosting.co.za>
2016-08-11 18:41:43vekylinkissue27539 messages
2016-08-11 18:41:43vekycreate