]> granicus.if.org Git - python/commitdiff
Merged revisions 72887 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Sun, 24 May 2009 15:41:43 +0000 (15:41 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Sun, 24 May 2009 15:41:43 +0000 (15:41 +0000)
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
Misc/NEWS
Modules/fcntlmodule.c

index 8d416b6f378c62498204860de83a4cc1a485e9f0..1977214a0f1f43b3469dd5f8aafef89221c203c9 100755 (executable)
@@ -57,7 +57,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)
 
@@ -81,6 +81,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)
index 6fdbd0bcb2fdb94035028252e7473c998082098f..6264e58fa3091b4a180411fd8511c8eeab226b79 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -50,6 +50,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 #1983: Fix functions taking or returning a process identifier to use
   the dedicated C type ``pid_t`` instead of a C ``int``. Some platforms have
   a process identifier type wider than the standard C integer type.
index ab7f22d37fe2ca72a8e72eece4c2090236b3ec4c..a333a34bea9c12375ef4f531d51fac9e9c40d2e7 100644 (file)
@@ -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;