]> granicus.if.org Git - python/commit
bpo-32968: Make modulo and floor division involving Fraction and float consistent...
authorElias Zamaria <mikez302@gmail.com>
Mon, 27 Aug 2018 06:59:28 +0000 (23:59 -0700)
committerMark Dickinson <mdickinson@enthought.com>
Mon, 27 Aug 2018 06:59:28 +0000 (07:59 +0100)
commit393f1ff62e032f20adaed2613a9e2d2d6bcb1eb3
tree4fa1002c40971a5352722a49a64ed1ae1415f40a
parent74734f73ca3cdb48d4d51139512b6828c2734252
bpo-32968: Make modulo and floor division involving Fraction and float consistent with other operations (#5956)

Make mixed-type `%` and `//` operations involving `Fraction` and `float` objects behave like all other mixed-type arithmetic operations: first the `Fraction` object is converted to a `float`, then the `float` operation is performed as normal. This fixes some surprising corner cases, like `Fraction('1/3') % inf` giving a NaN.

Thanks Elias Zamaria for the patch.
Lib/fractions.py
Lib/test/test_fractions.py
Misc/ACKS
Misc/NEWS.d/next/Library/2018-03-18-15-57-32.bpo-32968.E4G7BO.rst [new file with mode: 0644]