[pypy-commit] pypy stdlib-3.2.5: fix a c int overflow. refs cpython issue15989

pjenvey noreply at buildbot.pypy.org
Wed Apr 2 22:00:40 CEST 2014


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: stdlib-3.2.5
Changeset: r70406:66760d2d4d71
Date: 2014-04-02 12:59 -0700
http://bitbucket.org/pypy/pypy/changeset/66760d2d4d71/

Log:	fix a c int overflow. refs cpython issue15989

diff --git a/pypy/module/_io/test/test_textio.py b/pypy/module/_io/test/test_textio.py
--- a/pypy/module/_io/test/test_textio.py
+++ b/pypy/module/_io/test/test_textio.py
@@ -1,6 +1,12 @@
 class AppTestTextIO:
     spaceconfig = dict(usemodules=['_io', '_locale'])
 
+    def setup_class(cls):
+        from rpython.rlib.rarithmetic import INT_MAX, UINT_MAX
+        space = cls.space
+        cls.w_INT_MAX = space.wrap(INT_MAX)
+        cls.w_UINT_MAX = space.wrap(UINT_MAX)
+
     def test_constructor(self):
         import _io
         r = _io.BytesIO(b"\xc3\xa9\n\n")
@@ -380,6 +386,14 @@
         f = _io.TextIOWrapper(sys.stderr.buffer)
         assert f.encoding == encoding
 
+    def test_device_encoding_ovf(self):
+        import _io
+        b = _io.BytesIO()
+        b.fileno = lambda: self.INT_MAX + 1
+        raises(OverflowError, _io.TextIOWrapper, b)
+        b.fileno = lambda: self.UINT_MAX + 1
+        raises(OverflowError, _io.TextIOWrapper, b)
+
 
 class AppTestIncrementalNewlineDecoder:
     def test_newline_decoder(self):
diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -1353,7 +1353,7 @@
     """
     return space.wrap(os.ctermid())
 
- at unwrap_spec(fd=int)
+ at unwrap_spec(fd=c_int)
 def device_encoding(space, fd):
     """device_encoding(fd) -> str
 


More information about the pypy-commit mailing list