[pypy-commit] pypy py3k: fix fcntl
pjenvey
noreply at buildbot.pypy.org
Wed Apr 30 01:12:05 CEST 2014
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r71076:14237185e6ff
Date: 2014-04-29 16:09 -0700
http://bitbucket.org/pypy/pypy/changeset/14237185e6ff/
Log: fix fcntl
diff --git a/pypy/module/fcntl/interp_fcntl.py b/pypy/module/fcntl/interp_fcntl.py
--- a/pypy/module/fcntl/interp_fcntl.py
+++ b/pypy/module/fcntl/interp_fcntl.py
@@ -103,7 +103,7 @@
if rv < 0:
raise _get_error(space, "fcntl")
arg = rffi.charpsize2str(ll_arg, len(arg))
- return space.wrap(arg)
+ return space.wrapbytes(arg)
finally:
lltype.free(ll_arg, flavor='raw')
@@ -112,7 +112,7 @@
rv = fcntl_int(fd, op, intarg)
if rv < 0:
raise _get_error(space, "fcntl")
- return space.wrapbytes(rv)
+ return space.wrap(rv)
@unwrap_spec(op=int)
def flock(space, w_fd, op):
@@ -204,7 +204,8 @@
try:
rwbuffer = space.writebuf_w(w_arg)
except OperationError, e:
- if not e.match(space, space.w_TypeError):
+ if not (e.match(space, space.w_TypeError) or
+ e.match(space, space.w_BufferError)):
raise
else:
arg = rwbuffer.as_str()
@@ -217,7 +218,7 @@
if mutate_flag != 0:
rwbuffer.setslice(0, arg)
return space.wrap(rv)
- return space.wrap(arg)
+ return space.wrapbytes(arg)
finally:
lltype.free(ll_arg, flavor='raw')
@@ -238,7 +239,7 @@
if rv < 0:
raise _get_error(space, "ioctl")
arg = rffi.charpsize2str(ll_arg, len(arg))
- return space.wrap(arg)
+ return space.wrapbytes(arg)
finally:
lltype.free(ll_arg, flavor='raw')
@@ -247,4 +248,4 @@
rv = ioctl_int(fd, op, intarg)
if rv < 0:
raise _get_error(space, "ioctl")
- return space.wrapbytes(rv)
+ return space.wrap(rv)
diff --git a/pypy/module/fcntl/test/test_fcntl.py b/pypy/module/fcntl/test/test_fcntl.py
--- a/pypy/module/fcntl/test/test_fcntl.py
+++ b/pypy/module/fcntl/test/test_fcntl.py
@@ -47,8 +47,6 @@
assert fcntl.fcntl(f, 1, 0) == 0
assert fcntl.fcntl(f, 2, "foo") == b"foo"
assert fcntl.fcntl(f, 2, memoryview(b"foo")) == b"foo"
- exc = raises(TypeError, fcntl.fcntl, f, 2, memoryview(b"foo"))
- assert 'integer' in str(exc.value)
try:
os.O_LARGEFILE
@@ -225,12 +223,10 @@
assert buf.tostring() == expected
buf = array.array('i', [0])
- res = fcntl.ioctl(mfd, TIOCGPGRP, buffer(buf))
- assert res == expected
- assert buf.tostring() == b'\x00' * 4
+ res = fcntl.ioctl(mfd, TIOCGPGRP, memoryview(buf))
+ assert res == 0
+ assert buf.tostring() == expected
- exc = raises(TypeError, fcntl.ioctl, mfd, TIOCGPGRP, memoryview(b'abc'))
- assert 'integer' in str(exc.value)
exc = raises(TypeError, fcntl.ioctl, mfd, TIOCGPGRP, memoryview(b'abc'), False)
assert str(exc.value) == "ioctl requires a file or file descriptor, an integer and optionally an integer or buffer argument"
More information about the pypy-commit
mailing list