[pypy-commit] pypy py3k: All types are now printed as "<class ..."

amauryfa noreply at buildbot.pypy.org
Sun Dec 18 19:34:26 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r50668:81bc80bf4f62
Date: 2011-12-18 17:13 +0100
http://bitbucket.org/pypy/pypy/changeset/81bc80bf4f62/

Log:	All types are now printed as "<class ..."

diff --git a/pypy/objspace/std/test/test_typeobject.py b/pypy/objspace/std/test/test_typeobject.py
--- a/pypy/objspace/std/test/test_typeobject.py
+++ b/pypy/objspace/std/test/test_typeobject.py
@@ -739,10 +739,10 @@
         class A(object):
             pass
         assert repr(A) == "<class 'a.A'>"
-        assert repr(type(type)) == "<type 'type'>" 
-        assert repr(complex) == "<type 'complex'>"
-        assert repr(property) == "<type 'property'>"
-        assert repr(TypeError) == "<type 'exceptions.TypeError'>"
+        assert repr(type(type)) == "<class 'type'>" 
+        assert repr(complex) == "<class 'complex'>"
+        assert repr(property) == "<class 'property'>"
+        assert repr(TypeError) == "<class 'exceptions.TypeError'>"
         
     def test_invalid_mro(self):
         class A(object):
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -872,19 +872,14 @@
 
 def repr__Type(space, w_obj):
     w_mod = w_obj.get_module()
-    if not space.isinstance_w(w_mod, space.w_str):
+    if not space.isinstance_w(w_mod, space.w_unicode):
         mod = None
     else:
         mod = space.str_w(w_mod)
-    if (not w_obj.is_heaptype() or
-        (mod == '__builtin__' or mod == 'exceptions')):
-        kind = 'type'
+    if mod is not None and mod !='builtins':
+        return space.wrap("<class '%s.%s'>" % (mod, w_obj.name))
     else:
-        kind = 'class'
-    if mod is not None and mod !='builtins':
-        return space.wrap("<%s '%s.%s'>" % (kind, mod, w_obj.name))
-    else:
-        return space.wrap("<%s '%s'>" % (kind, w_obj.name))
+        return space.wrap("<class '%s'>" % (w_obj.name))
 
 def getattr__Type_ANY(space, w_type, w_name):
     name = space.str_w(w_name)


More information about the pypy-commit mailing list