[pypy-commit] pypy py3.5: Use the __qualname__ of the class when computing the default repr of instances
arigo
pypy.commits at gmail.com
Sun Jan 15 11:53:26 EST 2017
Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r89586:c2ed167889ea
Date: 2017-01-15 17:52 +0100
http://bitbucket.org/pypy/pypy/changeset/c2ed167889ea/
Log: Use the __qualname__ of the class when computing the default repr of
instances
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -715,7 +715,7 @@
def getfulltypename(self, w_obj):
w_type = self.type(w_obj)
- classname = w_type.name.decode('utf-8')
+ classname = w_type.getqualname(self)
if w_type.is_heaptype():
w_module = w_type.lookup("__module__")
if w_module is not None:
diff --git a/pypy/objspace/std/test/test_userobject.py b/pypy/objspace/std/test/test_userobject.py
--- a/pypy/objspace/std/test/test_userobject.py
+++ b/pypy/objspace/std/test/test_userobject.py
@@ -221,8 +221,9 @@
class Foo(object):
pass
Foo.__module__ = 'a.b.c'
+ Foo.__qualname__ = 'd.Foo'
s = repr(Foo())
- assert s.startswith('<a.b.c.Foo object at ')
+ assert s.startswith('<a.b.c.d.Foo object at ')
def test_repr_nonascii(self):
Japan = type('日本', (), dict(__module__='日本国'))
More information about the pypy-commit
mailing list