[issue32968] Fraction modulo infinity should behave consistently with other numbers

Mark Dickinson report at bugs.python.org
Wed Feb 28 11:12:20 EST 2018


Mark Dickinson <dickinsm at gmail.com> added the comment:

I'm not quite sure why `Fraction_instance % float_instance` wouldn't simply convert the `Fraction` to a `float` and then use the usual floating-point mod. There's the issue that you want to maintain consistency with the floordiv operation, but if `Fraction_instance // float_instance` _also_ converts its first argument to float, then that consistency should follow automatically.

That's the pattern that's followed for most of the other binary arithmetic operators. It looks like the inconsistency is caused by using `_operator_fallbacks` for most of the operations, but doing something more ad-hoc for modulo.

I agree that the current behaviour is surprising.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32968>
_______________________________________


More information about the Python-bugs-list mailing list