Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r58203:273ee4e3a74c
Date: 2012-10-18 11:28 +0200
http://bitbucket.org/pypy/pypy/changeset/273ee4e3a74c/

Log:    issue1292: simplify the repr() of types, now that most built-in
        types are indeed written in RPython and not in pure Python. We'll
        need to check this night's lib-python test run to be sure it's
        correct...

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
@@ -743,7 +743,13 @@
         assert repr(complex) == "<type 'complex'>"
         assert repr(property) == "<type 'property'>"
         assert repr(TypeError) == "<type 'exceptions.TypeError'>"
-        
+
+    def test_repr_issue1292(self):
+        d = {'object': object}    # no __name__
+        exec "class A(object): pass\n" in d
+        assert d['A'].__module__ == '__builtin__'    # obscure, follows CPython
+        assert repr(d['A']) == "<class 'A'>"
+
     def test_invalid_mro(self):
         class A(object):
             pass
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
@@ -876,8 +876,7 @@
         mod = None
     else:
         mod = space.str_w(w_mod)
-    if (not w_obj.is_heaptype() or
-        (mod == '__builtin__' or mod == 'exceptions')):
+    if not w_obj.is_heaptype():
         kind = 'type'
     else:
         kind = 'class'
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to