[Python-checkins] r72887 - in python/trunk: Lib/test/test_fcntl.py Misc/NEWS Modules/fcntlmodule.c

antoine.pitrou python-checkins at python.org
Sun May 24 17:40:09 CEST 2009


Author: antoine.pitrou
Date: Sun May 24 17:40:09 2009
New Revision: 72887
Log:
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).
Modified:
 python/trunk/Lib/test/test_fcntl.py
 python/trunk/Misc/NEWS
 python/trunk/Modules/fcntlmodule.c
Modified: python/trunk/Lib/test/test_fcntl.py
==============================================================================
--- python/trunk/Lib/test/test_fcntl.py	(original)
+++ python/trunk/Lib/test/test_fcntl.py	Sun May 24 17:40:09 2009
@@ -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,6 +85,21 @@
 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)
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Sun May 24 17:40:09 2009
@@ -302,6 +302,10 @@
 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.
 
Modified: python/trunk/Modules/fcntlmodule.c
==============================================================================
--- python/trunk/Modules/fcntlmodule.c	(original)
+++ python/trunk/Modules/fcntlmodule.c	Sun May 24 17:40:09 2009
@@ -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;


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /