[pypy-commit] pypy py3k: backout 21b2914fdb96 pending type.name switching to unicode

pjenvey noreply at buildbot.pypy.org
Tue Nov 15 20:10:04 CET 2011


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r49444:706419ee2d49
Date: 2011-11-15 10:58 -0800
http://bitbucket.org/pypy/pypy/changeset/706419ee2d49/

Log:	backout 21b2914fdb96 pending type.name switching to unicode

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)) == "<class 'type'>"
-        assert repr(complex) == "<class 'complex'>"
-        assert repr(property) == "<class 'property'>"
-        assert repr(TypeError) == "<class 'TypeError'>"
+        assert repr(type(type)) == "<type 'type'>" 
+        assert repr(complex) == "<type 'complex'>"
+        assert repr(property) == "<type 'property'>"
+        assert repr(TypeError) == "<type '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
@@ -518,10 +518,10 @@
     def get_module_type_name(w_self):
         space = w_self.space
         w_mod = w_self.get_module()
-        if not space.isinstance_w(w_mod, space.w_unicode):
+        if not space.isinstance_w(w_mod, space.w_str):
             mod = 'builtins'
         else:
-            mod = space.unicode_w(w_mod)
+            mod = space.str_w(w_mod)
         if mod != 'builtins':
             return '%s.%s' % (mod, w_self.name)
         else:
@@ -871,14 +871,19 @@
 
 def repr__Type(space, w_obj):
     w_mod = w_obj.get_module()
-    if not space.isinstance_w(w_mod, space.w_unicode):
+    if not space.isinstance_w(w_mod, space.w_str):
         mod = None
     else:
-        mod = space.unicode_w(w_mod)
-    if mod is not None and mod != 'builtins':
-        return space.wrap("<class '%s.%s'>" % (mod, w_obj.name))
+        mod = space.str_w(w_mod)
+    if (not w_obj.is_heaptype() or
+        (mod == '__builtin__' or mod == 'exceptions')):
+        kind = 'type'
     else:
-        return space.wrap("<class '%s'>" % (w_obj.name))
+        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))
 
 def getattr__Type_ANY(space, w_type, w_name):
     name = space.str_w(w_name)


More information about the pypy-commit mailing list