[issue27792] bool % int has inconsistent return type.

2016-09-10 Thread Mark Dickinson
Mark Dickinson added the comment: > BTW, Mark, do you think the fast path in long_mod is really needed? Actually > the same fast path has already existed in l_divmod. See issue 28060 for fast path cleanup. -- ___ Python tracker

[issue27792] bool % int has inconsistent return type.

2016-08-22 Thread Xiang Zhang
Xiang Zhang added the comment: Thanks for your work too. ;) You does the most important change. -- ___ Python tracker ___

[issue27792] bool % int has inconsistent return type.

2016-08-22 Thread Mark Dickinson
Mark Dickinson added the comment: issue27792_v2.patch LGTM. Thanks for the fix! -- resolution: -> fixed stage: needs patch -> resolved status: open -> closed ___ Python tracker

[issue27792] bool % int has inconsistent return type.

2016-08-22 Thread Roundup Robot
Roundup Robot added the comment: New changeset d998d87f0aa0 by Mark Dickinson in branch 'default': Issue #27792: force int return type for modulo operations involving bools. https://hg.python.org/cpython/rev/d998d87f0aa0 -- nosy: +python-dev ___

[issue27792] bool % int has inconsistent return type.

2016-08-22 Thread Xiang Zhang
Xiang Zhang added the comment: Oh, sorry. I forgot about long_long. Actually I did think for a while to search for a good function here. :( v2 uses long_long now. > I agree that the fast paths need looking at; it seems there's a fair bit of > redundancy there. But not in this issue, please!

[issue27792] bool % int has inconsistent return type.

2016-08-22 Thread Mark Dickinson
Mark Dickinson added the comment: > BTW, Mark, do you think the fast path in long_mod is really needed? I agree that the fast paths need looking at; it seems there's a fair bit of redundancy there. But not in this issue, please! -- ___ Python

[issue27792] bool % int has inconsistent return type.

2016-08-22 Thread Mark Dickinson
Mark Dickinson added the comment: Thanks for the patch. I think what we really want here is a call to `long_long` rather than `PyNumber_Long`; `PyNumber_Long` includes all the conversions using `__trunc__`, etc., which we don't need here. -- ___

[issue27792] bool % int has inconsistent return type.

2016-08-22 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +haypo ___ Python tracker ___ ___

[issue27792] bool % int has inconsistent return type.

2016-08-21 Thread Xiang Zhang
Xiang Zhang added the comment: issue27792.patch tries to fix this. BTW, Mark, do you think the fast path in long_mod is really needed? Actually the same fast path has already existed in l_divmod. -- keywords: +patch Added file: http://bugs.python.org/file44185/issue27792.patch

[issue27792] bool % int has inconsistent return type.

2016-08-19 Thread Terry J. Reedy
Terry J. Reedy added the comment: This can only happen because of a hole in the tests. test_bool.BoolTest.test_math appears to test every binary int op, including bitwise, *except* %. After self.assertIsNot(False/1, False) add self.assertEqual(False%1, 0)

[issue27792] bool % int has inconsistent return type.

2016-08-19 Thread Mark Dickinson
Changes by Mark Dickinson : -- assignee: -> mark.dickinson ___ Python tracker ___ ___

[issue27792] bool % int has inconsistent return type.

2016-08-18 Thread Mark Dickinson
Mark Dickinson added the comment: FWIW, I'd suggest not changing this in 3.5; only in 3.6. It's a fairly harmless bug that's been with us throughout the 3.x series so far (and even back into 2.x, if you start looking at behaviour with subclasses of `long`). --

[issue27792] bool % int has inconsistent return type.

2016-08-18 Thread Xiang Zhang
Changes by Xiang Zhang : -- nosy: +xiang.zhang ___ Python tracker ___ ___ Python-bugs-list

[issue27792] bool % int has inconsistent return type.

2016-08-18 Thread Mark Dickinson
Mark Dickinson added the comment: Ah, it looks as though this is already fixed in master, and it's probably not worth fixing for 3.5. Closing. -- status: open -> closed ___ Python tracker

[issue27792] bool % int has inconsistent return type.

2016-08-18 Thread Mark Dickinson
Mark Dickinson added the comment: Whoops; no, it's not fixed. 3.6 introduced a fast path that has the side-effect of fixing this issue for the `True % 2` case, but not for all cases: >>> False % 2 False >>> True % 2 1 >>> class MyInt(int): pass ... >>> type(MyInt(0) % 6) >>> type(MyInt(1) %

[issue27792] bool % int has inconsistent return type.

2016-08-18 Thread Mark Dickinson
Changes by Mark Dickinson : -- resolution: -> out of date ___ Python tracker ___ ___

[issue27792] bool % int has inconsistent return type.

2016-08-18 Thread Mark Dickinson
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]