[issue27436] Strange code in selectors.KqueueSelector

2021-01-01 Thread David Beazley
Change by David Beazley : -- stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing list Uns

[issue27436] Strange code in selectors.KqueueSelector

2016-07-01 Thread Xiang Zhang
Xiang Zhang added the comment: Oh, sorry. My focus seem to be on the wrong place. I thought David is arguing something about the constants are bitmasks or not. It's my fault. But actually the current code looks very clearly and I can tell from it that EVENT_* are bitmasks and KQ_FILTER_* are n

[issue27436] Strange code in selectors.KqueueSelector

2016-07-01 Thread Demur Rumed
Demur Rumed added the comment: Xiang: pause a moment to read the code being discussed. event before the |= is 0. You're saying flag must READ xor WRITE xor neither. Then only one if can be taken. Therefore events |= EVENT_* will always happen with events == 0, therefore it can be events = EVEN

[issue27436] Strange code in selectors.KqueueSelector

2016-07-01 Thread David Beazley
David Beazley added the comment: I don't see any possible way that you would ever get events = EVENT_READ | EVENT_WRITE if the flag is a single value (e.g., KQ_FILTER_READ) and the flag itself is not a bitmask. Only one of those == tests will ever be True. There is no need to use |=. Unles

[issue27436] Strange code in selectors.KqueueSelector

2016-07-01 Thread Berker Peksag
Changes by Berker Peksag : -- nosy: +neologix ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue27436] Strange code in selectors.KqueueSelector

2016-07-01 Thread Xiang Zhang
Xiang Zhang added the comment: But EVENT_* are. If you use =, events can only be either EVENT_READ or EVENT_WRITE, not EVENT_READ & EVENT_WRITE. EVENT_* != KQ_FILTER_*. -- ___ Python tracker __

[issue27436] Strange code in selectors.KqueueSelector

2016-07-01 Thread David Beazley
David Beazley added the comment: If the KQ_FILTER constants aren't bitmasks, it seems that the code could be simplified to the last version then. At the least, it would remove a few unnecessary calculations.Again, a very minor thing (I only stumbled onto it by accident really). -

[issue27436] Strange code in selectors.KqueueSelector

2016-07-01 Thread Xiang Zhang
Xiang Zhang added the comment: What I am saying is that EVENT_* (1, 2) are bit_masks while KQ_FILTER_* not (-1, -2, -3, -4). So you should use |= with EVENT_* and == with KQ_FILTER_*. It seems not a bug. :) -- ___ Python tracker

[issue27436] Strange code in selectors.KqueueSelector

2016-07-01 Thread Xiang Zhang
Xiang Zhang added the comment: EVENT_* and KQ_FILTER_* are two different sets of constants. EVENT_* represent event types of the abstract event and KQ_FILTER_* represent the kevent filter type. EVENT_* can be combined while kevent.filter can only get one type. -- nosy: +xiang.zhang __

[issue27436] Strange code in selectors.KqueueSelector

2016-07-01 Thread David Beazley
New submission from David Beazley: Not so much a bug, but an observation based on reviewing the implementation of the selectors.KqueueSelector class. In that class there is the select() method: def select(self, timeout=None): timeout = None if timeout is None else max(timeo