[pypy-svn] r60980 - in pypy/trunk/pypy/module/fcntl: . test
fijal at codespeak.net
fijal at codespeak.net
Wed Jan 14 23:37:46 CET 2009
Author: fijal
Date: Wed Jan 14 23:37:45 2009
New Revision: 60980
Modified:
pypy/trunk/pypy/module/fcntl/interp_fcntl.py
pypy/trunk/pypy/module/fcntl/test/test_fcntl.py
Log:
how-this-could-have-ever-worked kind of checkin (and a test)
Modified: pypy/trunk/pypy/module/fcntl/interp_fcntl.py
==============================================================================
--- pypy/trunk/pypy/module/fcntl/interp_fcntl.py (original)
+++ pypy/trunk/pypy/module/fcntl/interp_fcntl.py Wed Jan 14 23:37:45 2009
@@ -167,7 +167,7 @@
rffi.setintfield(l, 'c_l_whence', 0)
rffi.setintfield(l, 'c_l_start', 0)
rffi.setintfield(l, 'c_l_len', 0)
- op = [F_SETLKW, F_SETLK][op & LOCK_NB]
+ op = [F_SETLKW, F_SETLK][int(bool(op & LOCK_NB))]
op = rffi.cast(rffi.INT, op) # C long => C int
fcntl_flock(fd, op, l)
lltype.free(l, flavor='raw')
@@ -213,11 +213,7 @@
l.c_l_whence = rffi.cast(rffi.SHORT, whence)
try:
- try:
- op = [F_SETLKW, F_SETLK][op & LOCK_NB]
- except IndexError:
- raise OperationError(space.w_ValueError,
- space.wrap("invalid value for operation"))
+ op = [F_SETLKW, F_SETLK][int(bool(op & LOCK_NB))]
op = rffi.cast(rffi.INT, op) # C long => C int
fcntl_flock(fd, op, l)
finally:
Modified: pypy/trunk/pypy/module/fcntl/test/test_fcntl.py
==============================================================================
--- pypy/trunk/pypy/module/fcntl/test/test_fcntl.py (original)
+++ pypy/trunk/pypy/module/fcntl/test/test_fcntl.py Wed Jan 14 23:37:45 2009
@@ -191,3 +191,8 @@
res = fcntl.ioctl(0, TIOCGPGRP, "\x00\x00")
assert res == expected
+
+ def test_lockf_with_ex(self):
+ import fcntl
+ f = open(self.tmp, "w")
+ fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
More information about the Pypy-commit
mailing list