Index: Lib/test/test_fcntl.py =================================================================== --- Lib/test/test_fcntl.py (révision 72661) +++ Lib/test/test_fcntl.py (copie de travail) @@ -61,7 +61,7 @@ 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,7 +85,22 @@ 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: Modules/fcntlmodule.c =================================================================== --- Modules/fcntlmodule.c (révision 72661) +++ Modules/fcntlmodule.c (copie de travail) @@ -34,7 +34,7 @@ { int fd; int code; - int arg; + long arg; int ret; char *str; Py_ssize_t len; @@ -61,7 +61,7 @@ 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;