[issue25412] __floordiv__ in module fraction fails with TypeError instead of returning NotImplemented

Sergey Shashkov report at bugs.python.org
Fri Oct 16 14:14:07 EDT 2015


Sergey Shashkov added the comment:

OK,

then we should not change numbers.py.

And in fractions.py:

def __floordiv__(a, b):
        """a // b"""
        if isinstance(b, numbers.Complex) or hasattr(b, '__rtruediv__'):
            fr = a / b
            if fr != NotImplemented:
                return math.floor(a / b)
            else:
                return NotImplemented
        else:
            return NotImplemented

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25412>
_______________________________________


More information about the Python-bugs-list mailing list