Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r64695:1fc4fb3e2d15
Date: 2013-05-31 13:46 -0700
http://bitbucket.org/pypy/pypy/changeset/1fc4fb3e2d15/
Log: fix identifier handling in type's repr
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
@@ -1,3 +1,4 @@
+# encoding: utf-8
from pypy.objspace.std.model import W_Object
from pypy.objspace.std.stdtypedef import StdTypeDef
@@ -682,6 +683,9 @@
assert d['A'].__module__ == 'builtins' # obscure, follows CPython
assert repr(d['A']) == "<class 'A'>"
+ def test_repr_unicode(self):
+ assert repr(type('日本', (), {})) == "<class
'%s.日本'>" % __name__
+
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
@@ -1119,11 +1119,12 @@
if not space.isinstance_w(w_mod, space.w_unicode):
mod = None
else:
- mod = space.str_w(w_mod)
- if mod is not None and mod != 'builtins':
- return space.wrap("<class '%s.%s'>" % (mod, w_obj.name))
+ mod = space.unicode_w(w_mod)
+ name = w_obj.name.decode('utf-8')
+ if mod is not None and mod != u'builtins':
+ return space.wrap(u"<class '%s.%s'>" % (mod, name))
else:
- return space.wrap("<class '%s'>" % (w_obj.name))
+ return space.wrap(u"<class '%s'>" % (name))
def getattr__Type_ANY(space, w_type, w_name):
name = space.str_w(w_name)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit