Vedran Čačić added the comment:
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?
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27539>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com