Author: Matti Picus <[email protected]>
Branch: py3.6
Changeset: r98661:1c68a492a49e
Date: 2020-02-04 16:12 +0200
http://bitbucket.org/pypy/pypy/changeset/1c68a492a49e/

Log:    check for overflow in device_encoding (caused by a bad fileno)

diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -246,9 +246,14 @@
                 e.match(space, space.fromcache(Cache).w_unsupportedoperation)):
             raise
     else:
-        w_encoding = device_encoding(space, space.int_w(w_fileno))
-        if space.isinstance_w(w_encoding, space.w_unicode):
-            return w_encoding
+        try:
+            w_encoding = device_encoding(space, space.int_w(w_fileno))
+        except OverflowError:
+            raise oefmt(space.w_OverflowError,
+                        "Python int too large to convert to C int")
+        else:
+            if space.isinstance_w(w_encoding, space.w_unicode):
+                return w_encoding
 
     # On legacy systems or darwin, try app-level 
     # _bootlocale.getprefferedencoding(False)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to