[issue27792] bool % int has inconsistent return type.

Mark Dickinson report at bugs.python.org
Thu Aug 18 08:09:44 EDT 2016


New submission from Mark Dickinson:

Seen on reddit [1]: 

>>> True % 1
0
>>> True % 2
True

I believe that we should be returning an int in both these cases; this looks like a longobject.c fast path gone wrong.

[1] https://www.reddit.com/r/learnpython/comments/4y5bh1/can_someone_explain_why_true_1_0_but_true_2_true/

----------
messages: 273020
nosy: mark.dickinson
priority: normal
severity: normal
stage: needs patch
status: open
title: bool % int has inconsistent return type.
type: behavior
versions: Python 3.5, Python 3.6

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


More information about the Python-bugs-list mailing list