Author: Armin Rigo <[email protected]>
Branch: fix-descrmismatch-crash
Changeset: r97774:56cde2db6b50
Date: 2019-10-14 11:50 +0200
http://bitbucket.org/pypy/pypy/changeset/56cde2db6b50/
Log: Same fix for cStringIO
diff --git a/pypy/module/cStringIO/interp_stringio.py
b/pypy/module/cStringIO/interp_stringio.py
--- a/pypy/module/cStringIO/interp_stringio.py
+++ b/pypy/module/cStringIO/interp_stringio.py
@@ -7,6 +7,8 @@
class W_InputOutputType(W_Root):
+ exact_class_applevel_name = "StringI-or-StringO"
+
softspace = 0 # part of the file object API
def descr___iter__(self):
diff --git a/pypy/module/cStringIO/test/test_interp_stringio.py
b/pypy/module/cStringIO/test/test_interp_stringio.py
--- a/pypy/module/cStringIO/test/test_interp_stringio.py
+++ b/pypy/module/cStringIO/test/test_interp_stringio.py
@@ -204,3 +204,12 @@
import cStringIO
assert type(cStringIO.StringIO()) is cStringIO.OutputType
assert type(cStringIO.StringIO('')) is cStringIO.InputType
+
+ def test_error_message_wrong_self(self):
+ import cStringIO
+ unboundmeth = cStringIO.InputType.close
+ e = raises(TypeError, unboundmeth, 42)
+ assert "StringI" in str(e.value)
+ if hasattr(unboundmeth, 'im_func'):
+ e = raises(TypeError, unboundmeth.im_func, 42)
+ assert "'StringI-or-StringO'" in str(e.value)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit