Author: Amaury Forgeot d'Arc <[email protected]>
Branch:
Changeset: r78061:3f6c2b6ab6d5
Date: 2015-06-12 23:56 +0200
http://bitbucket.org/pypy/pypy/changeset/3f6c2b6ab6d5/
Log: Avoid a crash when TextIOWrapper is not fully initialized
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
@@ -436,6 +436,7 @@
W_TextIOBase._check_closed(self, space, message)
def descr_repr(self, space):
+ self._check_init(space)
w_name = space.findattr(self, space.wrap("name"))
if w_name is None:
w_name_str = space.wrap("")
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
@@ -252,6 +252,16 @@
t = _io.TextIOWrapper(NonbytesStream(u'a'))
t.read() == u'a'
+ def test_uninitialized(self):
+ import _io
+ t = _io.TextIOWrapper.__new__(_io.TextIOWrapper)
+ del t
+ t = _io.TextIOWrapper.__new__(_io.TextIOWrapper)
+ raises(Exception, repr, t)
+ raises(ValueError, t.read, 0)
+ t.__init__(_io.BytesIO())
+ assert t.read(0) == u''
+
class AppTestIncrementalNewlineDecoder:
def test_newline_decoder(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit