Author: Brian Kearns <[email protected]>
Branch: stdlib-2.7.4
Changeset: r60743:b7e7e4b395c7
Date: 2013-01-30 08:05 -0500
http://bitbucket.org/pypy/pypy/changeset/b7e7e4b395c7/
Log: fix/test fcntl ValueError on invalid fd
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1487,8 +1487,8 @@
raise OperationError(self.w_TypeError,
self.wrap("fileno() returned a non-integer")
)
- fd = self.c_int_w(w_fd)
- if fd < 0:
+ fd = self.int_w(w_fd)
+ if fd < 0 or fd > 2147483647:
raise operationerrfmt(self.w_ValueError,
"file descriptor cannot be a negative integer (%d)", fd
)
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
@@ -36,6 +36,10 @@
raises(TypeError, fcntl.fcntl, "foo")
raises(TypeError, fcntl.fcntl, f, "foo")
raises(TypeError, fcntl.fcntl, F("foo"), 1)
+ raises(ValueError, fcntl.fcntl, 2147483647 + 1, 1, 0)
+ raises(ValueError, fcntl.fcntl, F(2147483647 + 1), 1, 0)
+ raises(ValueError, fcntl.fcntl, -2147483648 - 1, 1, 0)
+ raises(ValueError, fcntl.fcntl, F(-2147483648 - 1), 1, 0)
raises(ValueError, fcntl.fcntl, -1, 1, 0)
raises(ValueError, fcntl.fcntl, F(-1), 1, 0)
raises(ValueError, fcntl.fcntl, F(long(-1)), 1, 0)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit