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

Created on 2011-05-01 18:26 by DragonSA, last changed 2014-03-10 15:28 by DragonSA.

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 (10)
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.
History
Date User Action Args
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