Author: Philip Jenvey <pjen...@underboss.org>
Branch: py3k
Changeset: r60358:3e9bb91ae0d4
Date: 2013-01-22 18:29 -0800
http://bitbucket.org/pypy/pypy/changeset/3e9bb91ae0d4/

Log:    accept strs in fcntl.ioctl, 2to3

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
@@ -248,14 +248,19 @@
     except OperationError, e:
         if not e.match(space, space.w_TypeError):
             raise
-    else:
-        ll_arg = rffi.str2charp(arg)
-        rv = ioctl_str(fd, op, ll_arg)
-        arg = rffi.charpsize2str(ll_arg, len(arg))
-        lltype.free(ll_arg, flavor='raw')
-        if rv < 0:
-            raise _get_error(space, "ioctl")
-        return space.wrapbytes(arg)
+        try:
+            arg = space.str_w(w_arg)
+        except OperationError, e:
+            if not e.match(space, space.w_TypeError):
+                raise
+            raise OperationError(
+                space.w_TypeError,
+                space.wrap("int or string or buffer required"))
 
-    raise OperationError(space.w_TypeError,
-                         space.wrap("int or string or buffer required"))
+    ll_arg = rffi.str2charp(arg)
+    rv = ioctl_str(fd, op, ll_arg)
+    arg = rffi.charpsize2str(ll_arg, len(arg))
+    lltype.free(ll_arg, flavor='raw')
+    if rv < 0:
+        raise _get_error(space, "ioctl")
+    return space.wrapbytes(arg)
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
@@ -115,7 +115,7 @@
             rval = 2
             try:
                 fcntl.flock(open(f.name, f.mode), fcntl.LOCK_EX | 
fcntl.LOCK_NB)
-            except IOError, e:
+            except IOError as e:
                 if e.errno not in (errno.EACCES, errno.EAGAIN):
                     raise
                 rval = 0
@@ -152,7 +152,7 @@
             rval = 2
             try:
                 fcntl.lockf(open(f.name, f.mode), fcntl.LOCK_EX | 
fcntl.LOCK_NB)
-            except IOError, e:
+            except IOError as e:
                 if e.errno not in (errno.EACCES, errno.EAGAIN):
                     raise
                 rval = 0
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to