Author: Armin Rigo <[email protected]>
Branch: fix-descrmismatch-crash
Changeset: r97772:c13fae180ec6
Date: 2019-10-14 11:45 +0200
http://bitbucket.org/pypy/pypy/changeset/c13fae180ec6/

Log:    fix the error message also for W_AbstractBytesObject

diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -24,6 +24,7 @@
 
 class W_AbstractBytesObject(W_Root):
     __slots__ = ()
+    exact_class_applevel_name = 'str'
 
     def is_w(self, space, w_other):
         if not isinstance(w_other, W_AbstractBytesObject):
diff --git a/pypy/objspace/std/test/test_bytesobject.py 
b/pypy/objspace/std/test/test_bytesobject.py
--- a/pypy/objspace/std/test/test_bytesobject.py
+++ b/pypy/objspace/std/test/test_bytesobject.py
@@ -933,3 +933,10 @@
     def test_add(self):
         assert 'abc' + 'abc' == 'abcabc'
         assert isinstance('abc' + u'\u03a3', unicode)
+
+    def test_error_message_wrong_self(self):
+        e = raises(TypeError, bytes.upper, 42)
+        assert "str" in str(e.value)
+        if hasattr(bytes.upper, 'im_func'):
+            e = raises(TypeError, bytes.upper.im_func, 42)
+            assert "'str'" in str(e.value)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to