Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(32)

#23591: Add IntFlags

Can't Edit
Can't Publish+Mail
Start Review
Created:
2 years, 9 months ago by storchaka+cpython
Modified:
1 year, 3 months ago
Reviewers:
vedgar, ethan
CC:
barry, rhettinger, ezio.melotti, r.david.murray, eli.bendersky, stoneleaf, devnull_psf.upfronthosting.co.za, storchaka, josh.rosenberg, veky
Visibility:
Public.

Patch Set 1 #

Patch Set 2 #

Patch Set 3 #

Patch Set 4 #

Total comments: 3

Patch Set 5 #

Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Lib/enum.py View 1 2 3 4 1 chunk +1 line, -6 lines 0 comments Download

Messages

Total messages: 7
veky
I hope this is the right way to send this note. http://bugs.python.org/review/23591/diff/18270/Lib/enum.py File Lib/enum.py (right): ...
1 year, 3 months ago #1
stoneleaf
http://bugs.python.org/review/23591/diff/18270/Lib/enum.py File Lib/enum.py (right): http://bugs.python.org/review/23591/diff/18270/Lib/enum.py#newcode789 Lib/enum.py:789: while 'looking for the highest bit': Excellent, thanks!
1 year, 3 months ago #2
stoneleaf
http://bugs.python.org/review/23591/diff/18270/Lib/enum.py File Lib/enum.py (right): http://bugs.python.org/review/23591/diff/18270/Lib/enum.py#newcode789 Lib/enum.py:789: while 'looking for the highest bit': On 2016/09/02 09:03:14, ...
1 year, 3 months ago #3
veky
On 2016/09/02 09:08:51, stoneleaf wrote: > Using bit_length() put me in an infinite loop. > ...
1 year, 3 months ago #4
veky
Ah, now I see the code. It should be the same, unless you call _high_bit ...
1 year, 3 months ago #5
stoneleaf
On 2016/09/02 13:31:26, veky wrote: > Ah, now I see the code. It should be ...
1 year, 3 months ago #6
veky
1 year, 3 months ago #7
On 2016/09/02 23:53:27, stoneleaf wrote:
> On 2016/09/02 13:31:26, veky wrote:
> > Ah, now I see the code. It should be the same, unless you call
> > _high_bit with a negative number, in which case you have bigger
> > problems. ;-o Are you sure that _that_ change introduced an infinite
> > loop?
> 
> It was the only change I made, so yeah, I'm sure.
> 
> Ah, here's the problem:
> 
> >>> from enum import _high_bit
> >>> for i in range(18):
> ...   print('%2d | %3d  %3d' % (i, _high_bit(i), i.bit_length()))
> ... 
>  0 |  -1    0
>  1 |   0    1
>  2 |   1    2
>  3 |   1    2
>  4 |   2    3
>  5 |   2    3
>  6 |   2    3
>  7 |   2    3
>  8 |   3    4
>  9 |   3    4
> 10 |   3    4
> 11 |   3    4
> 12 |   3    4
> 13 |   3    4
> 14 |   3    4
> 15 |   3    4
> 16 |   4    5
> 17 |   4    5
> 
> I tried using the bit_length() as-is, instead of subtracting one from it.

Yes, it's the classical "len != maximal index" fencepost error. :-)
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7