classification
Title: kevent does not accept KQ_NOTE_EXIT (and other (f)flags)
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.4, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: DragonSA, christian.heimes, koobs, ned.deily, python-dev, r.david.murray, ronaldoussoren
Priority: normal Keywords: patch

Created on 2011-05-01 18:26 by DragonSA, last changed 2014-10-12 16:55 by r.david.murray. This issue is now closed.

Files
File name Uploaded Description Edit
patch-Modules-selectmodule.c DragonSA, 2011-05-01 18:26
test_kqueue.py.diff DragonSA, 2014-03-10 15:28
test_kqueue.py.diff DragonSA, 2014-03-10 15:28
test_kqueue.py.diff DragonSA, 2014-03-10 15:28
test_kqueue.py.diff DragonSA, 2014-03-10 15:28
test_kqueue.py.diff DragonSA, 2014-03-10 15:28
test_kqueue.py.diff DragonSA, 2014-03-10 15:28
Messages (12)
msg134918 - (view) Author: David Naylor (DragonSA) Date: 2011-05-01 18:26
kevent does not accept all legitimate parameters, such as KQ_NOTE_EXIT.  

For example:
>> from select import *
>> kevent(0, KQ_FILTER_PROC, KQ_EV_ADD | KQ_EV_ENABLE, KQ_NOTE_EXIT)
OverflowError: signed integer is greater than maximum

While the following C code compiles (under -Wall -pedantic) without error, or warning:
"""
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>

int main(int argc, char **argv) {

  struct kevent ke;

  EV_SET(&ke, 0, EVFILT_PROC, EV_ADD | EV_ENABLE, NOTE_EXIT, 0, 0);

  return (0);

}
"""

Looking at the Modules/selectmodule.c file it is clear that the fields "flags" and "fflags" are defined as T_USHORT and T_UINT however the flags passed to PyArg_ParseTupleAndKeywords are 'h' and 'i' respectively (implying signed numbers).  

A workaround exists where values X > (2**31 - 1) are passed as (X - 2**32).  Also the attached patch fixes the error.
msg196124 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-08-25 12:48
The patch looks good to me.
msg196127 - (view) Author: Roundup Robot (python-dev) Date: 2013-08-25 12:58
New changeset d5334d8907dc by Christian Heimes in branch '3.3':
Issue #11973: Fix a problem in kevent. The flags and fflags fields are now
http://hg.python.org/cpython/rev/d5334d8907dc

New changeset 8345fb616cbd by Christian Heimes in branch 'default':
Issue #11973: Fix a problem in kevent. The flags and fflags fields are now
http://hg.python.org/cpython/rev/8345fb616cbd

New changeset 8eac75276e5b by Christian Heimes in branch '2.7':
Issue #11973: Fix a problem in kevent. The flags and fflags fields are now
http://hg.python.org/cpython/rev/8eac75276e5b
msg196128 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-08-25 12:59
Does somebody want to write a test for the issue, too?
msg213039 - (view) Author: David Naylor (DragonSA) Date: 2014-03-10 15:28
As requested, please find attached the unit tests that check `flags' can handle a u_short and `fflags' can handle a u_int.
msg213040 - (view) Author: David Naylor (DragonSA) Date: 2014-03-10 15:28
As requested, please find attached the unit tests that check `flags' can handle a u_short and `fflags' can handle a u_int.
msg213041 - (view) Author: David Naylor (DragonSA) Date: 2014-03-10 15:28
As requested, please find attached the unit tests that check `flags' can handle a u_short and `fflags' can handle a u_int.
msg213042 - (view) Author: David Naylor (DragonSA) Date: 2014-03-10 15:28
As requested, please find attached the unit tests that check `flags' can handle a u_short and `fflags' can handle a u_int.
msg213043 - (view) Author: David Naylor (DragonSA) Date: 2014-03-10 15:28
As requested, please find attached the unit tests that check `flags' can handle a u_short and `fflags' can handle a u_int.
msg213044 - (view) Author: David Naylor (DragonSA) Date: 2014-03-10 15:28
As requested, please find attached the unit tests that check `flags' can handle a u_short and `fflags' can handle a u_int.
msg229176 - (view) Author: Roundup Robot (python-dev) Date: 2014-10-12 16:53
New changeset 35542a32cd54 by R David Murray in branch '3.4':
#11973: add test for previously fixed kevent signed/unsigned bug.
https://hg.python.org/cpython/rev/35542a32cd54

New changeset a028299c9bc2 by R David Murray in branch 'default':
Merge: #11973: add test for previously fixed kevent signed/unsigned bug.
https://hg.python.org/cpython/rev/a028299c9bc2

New changeset 38fe09772b4f by R David Murray in branch '2.7':
#11973: add test for previously fixed kevent signed/unsigned bug.
https://hg.python.org/cpython/rev/38fe09772b4f
msg229177 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-10-12 16:55
Committed the test finally.  Thanks, David.
History
Date User Action Args
2014-10-12 16:55:04r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg229177

stage: commit review -> resolved
2014-10-12 16:53:58python-devsetmessages: + msg229176
2014-03-10 15:28:45DragonSAsetfiles: + test_kqueue.py.diff

messages: + msg213044
2014-03-10 15:28:44DragonSAsetfiles: + test_kqueue.py.diff

messages: + msg213043
2014-03-10 15:28:44DragonSAsetfiles: + test_kqueue.py.diff

messages: + msg213042
2014-03-10 15:28:43DragonSAsetfiles: + test_kqueue.py.diff

messages: + msg213041
2014-03-10 15:28:43DragonSAsetfiles: + test_kqueue.py.diff

messages: + msg213040
2014-03-10 15:28:42DragonSAsetfiles: + test_kqueue.py.diff
keywords: + patch
messages: + msg213039
2013-08-25 12:59:41christian.heimessetresolution: fixed
messages: + msg196128
stage: patch review -> commit review
2013-08-25 12:58:46python-devsetnosy: + python-dev
messages: + msg196127
2013-08-25 12:48:32christian.heimessetnosy: + christian.heimes

messages: + msg196124
versions: + Python 3.4, - Python 3.1, Python 3.2
2013-08-25 06:08:31koobssetnosy: + koobs
2011-05-01 18:50:22pitrousetnosy: + ronaldoussoren, ned.deily
stage: patch review

versions: - Python 2.6, Python 2.5, Python 3.4
2011-05-01 18:26:33DragonSAcreate