diff -r 5877c191b76e Lib/fractions.py --- a/Lib/fractions.py Fri Oct 16 12:21:37 2015 -0700 +++ b/Lib/fractions.py Fri Oct 16 23:58:52 2015 +0300 @@ -453,7 +453,10 @@ def __floordiv__(a, b): """a // b""" - return math.floor(a / b) + if isinstance(b, numbers.Complex): + return math.floor(a / b) + else: + return NotImplemented def __rfloordiv__(b, a): """a // b""" @@ -461,8 +464,11 @@ def __mod__(a, b): """a % b""" - div = a // b - return a - b * div + if isinstance(b, numbers.Complex): + div = a // b + return a - b * div + else: + return NotImplemented def __rmod__(b, a): """a % b"""