summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-05-24 15:40:09 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-05-24 15:40:09 (GMT)
commitd49e375eedf717c048fe7f803ee347a1572cc968 (patch)
treed2642c53592bb1785ad5755a52cc655d15ee8a74
parent4fe3858991581e22e365e51b5770547a0da33e4b (diff)
downloadcpython-d49e375eedf717c048fe7f803ee347a1572cc968.zip
cpython-d49e375eedf717c048fe7f803ee347a1572cc968.tar.gz
cpython-d49e375eedf717c048fe7f803ee347a1572cc968.tar.bz2
Issue #1309352: fcntl now converts its third arguments to a C `long` rather
than an int, which makes some operations possible under 64-bit Linux (e.g. DN_MULTISHOT with F_NOTIFY).
-rwxr-xr-xLib/test/test_fcntl.py17
-rw-r--r--Misc/NEWS4
-rw-r--r--Modules/fcntlmodule.c4
3 files changed, 22 insertions, 3 deletions
diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py
index 2c5ac11..c8ea7b7 100755
--- a/Lib/test/test_fcntl.py
+++ b/Lib/test/test_fcntl.py
@@ -61,7 +61,7 @@ class TestFcntl(unittest.TestCase):
self.f = None
def tearDown(self):
- if not self.f.closed:
+ if self.f and not self.f.closed:
self.f.close()
unlink(TESTFN)
@@ -85,6 +85,21 @@ class TestFcntl(unittest.TestCase):
rv = fcntl.fcntl(self.f, fcntl.F_SETLKW, lockdata)
self.f.close()
+ def test_fcntl_64_bit(self):
+ # Issue #1309352: fcntl shouldn't fail when the third arg fits in a
+ # C 'long' but not in a C 'int'.
+ try:
+ cmd = fcntl.F_NOTIFY
+ # This flag is larger than 2**31 in 64-bit builds
+ flags = fcntl.DN_MULTISHOT
+ except AttributeError:
+ self.skipTest("F_NOTIFY or DN_MULTISHOT unavailable")
+ fd = os.open(os.path.dirname(os.path.abspath(TESTFN)), os.O_RDONLY)
+ try:
+ fcntl.fcntl(fd, cmd, flags)
+ finally:
+ os.close(fd)
+
def test_main():
run_unittest(TestFcntl)
diff --git a/Misc/NEWS b/Misc/NEWS
index 96d5044..2a4d837 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -302,6 +302,10 @@ Core and Builtins
Library
-------
+- Issue #1309352: fcntl now converts its third arguments to a C `long` rather
+ than an int, which makes some operations possible under 64-bit Linux (e.g.
+ DN_MULTISHOT with F_NOTIFY).
+
- Issue #1424152: Fix for httplib, urllib2 to support SSL while working through
proxy. Original patch by Christopher Li, changes made by Senthil Kumaran.
diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c
index ab7f22d..a333a34 100644
--- a/Modules/fcntlmodule.c
+++ b/Modules/fcntlmodule.c
@@ -34,7 +34,7 @@ fcntl_fcntl(PyObject *self, PyObject *args)
{
int fd;
int code;
- int arg;
+ long arg;
int ret;
char *str;
Py_ssize_t len;
@@ -61,7 +61,7 @@ fcntl_fcntl(PyObject *self, PyObject *args)
PyErr_Clear();
arg = 0;
if (!PyArg_ParseTuple(args,
- "O&i|i;fcntl requires a file or file descriptor,"
+ "O&i|l;fcntl requires a file or file descriptor,"
" an integer and optionally a third integer or a string",
conv_descriptor, &fd, &code, &arg)) {
return NULL;