[pypy-commit] pypy stdlib-2.7.4: test and fix for FileIO(fd) overflow behavior
bdkearns
noreply at buildbot.pypy.org
Sun Apr 14 20:48:40 CEST 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch: stdlib-2.7.4
Changeset: r63336:6528f2c2dd65
Date: 2013-04-14 14:47 -0400
http://bitbucket.org/pypy/pypy/changeset/6528f2c2dd65/
Log: test and fix for FileIO(fd) overflow behavior
diff --git a/pypy/module/_io/interp_fileio.py b/pypy/module/_io/interp_fileio.py
--- a/pypy/module/_io/interp_fileio.py
+++ b/pypy/module/_io/interp_fileio.py
@@ -140,7 +140,7 @@
fd = -1
try:
- fd = space.int_w(w_name)
+ fd = space.c_int_w(w_name)
except OperationError, e:
pass
else:
diff --git a/pypy/module/_io/interp_io.py b/pypy/module/_io/interp_io.py
--- a/pypy/module/_io/interp_io.py
+++ b/pypy/module/_io/interp_io.py
@@ -119,7 +119,7 @@
buffering = DEFAULT_BUFFER_SIZE
if space.config.translation.type_system == 'lltype' and 'st_blksize' in STAT_FIELD_TYPES:
- fileno = space.int_w(space.call_method(w_raw, "fileno"))
+ fileno = space.c_int_w(space.call_method(w_raw, "fileno"))
try:
st = os.fstat(fileno)
except OSError:
diff --git a/pypy/module/_io/test/test_fileio.py b/pypy/module/_io/test/test_fileio.py
--- a/pypy/module/_io/test/test_fileio.py
+++ b/pypy/module/_io/test/test_fileio.py
@@ -21,6 +21,12 @@
assert f.closefd is True
f.close()
+ def test_invalid_fd(self):
+ import _io
+ raises(ValueError, _io.FileIO, -10)
+ raises(TypeError, _io.FileIO, 2 ** 31)
+ raises(TypeError, _io.FileIO, -2 ** 31 - 1)
+
def test_weakrefable(self):
import _io
from weakref import proxy
More information about the pypy-commit
mailing list