From 61f77b57fdfcc8a630667dda3cbb8c5ac502f438 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Sun, 24 May 2009 15:46:13 +0000 Subject: Merged revisions 72887 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r72887 | antoine.pitrou | 2009-05-24 17:40:09 +0200 (dim., 24 mai 2009) | 6 lines 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). ........ --- Lib/test/test_fcntl.py | 17 ++++++++++++++++- Misc/NEWS | 4 ++++ Modules/fcntlmodule.c | 4 ++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py index 72748f9..3c18f1d 100755 --- a/Lib/test/test_fcntl.py +++ b/Lib/test/test_fcntl.py @@ -59,7 +59,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) @@ -83,6 +83,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 378868e..110efbe 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -32,6 +32,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 #5761: Add the name of the underlying file to the repr() of various IO objects. diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c index 5331ea8..683c5b6 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; -- cgit v0.12