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).
This commit is contained in:
Antoine Pitrou 2009-05-24 15:40:09 +00:00
parent 4fe3858991
commit d49e375eed
3 changed files with 22 additions and 3 deletions

View File

@ -61,7 +61,7 @@ def setUp(self):
self.f = None self.f = None
def tearDown(self): def tearDown(self):
if not self.f.closed: if self.f and not self.f.closed:
self.f.close() self.f.close()
unlink(TESTFN) unlink(TESTFN)
@ -85,6 +85,21 @@ def test_fcntl_file_descriptor(self):
rv = fcntl.fcntl(self.f, fcntl.F_SETLKW, lockdata) rv = fcntl.fcntl(self.f, fcntl.F_SETLKW, lockdata)
self.f.close() 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(): def test_main():
run_unittest(TestFcntl) run_unittest(TestFcntl)

View File

@ -302,6 +302,10 @@ Core and Builtins
Library 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 - Issue #1424152: Fix for httplib, urllib2 to support SSL while working through
proxy. Original patch by Christopher Li, changes made by Senthil Kumaran. proxy. Original patch by Christopher Li, changes made by Senthil Kumaran.

View File

@ -34,7 +34,7 @@ fcntl_fcntl(PyObject *self, PyObject *args)
{ {
int fd; int fd;
int code; int code;
int arg; long arg;
int ret; int ret;
char *str; char *str;
Py_ssize_t len; Py_ssize_t len;
@ -61,7 +61,7 @@ fcntl_fcntl(PyObject *self, PyObject *args)
PyErr_Clear(); PyErr_Clear();
arg = 0; arg = 0;
if (!PyArg_ParseTuple(args, 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", " an integer and optionally a third integer or a string",
conv_descriptor, &fd, &code, &arg)) { conv_descriptor, &fd, &code, &arg)) {
return NULL; return NULL;