Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r62177:34a402b65a45
Date: 2013-03-07 11:39 -0800
http://bitbucket.org/pypy/pypy/changeset/34a402b65a45/
Log: passthru unicode in dict iter reprs
diff --git a/pypy/objspace/std/dictmultiobject.py
b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -1065,10 +1065,10 @@
def repr__DictViewKeys(space, w_dictview):
+ typename = space.type(w_dictview).getname(space).decode('utf-8')
w_seq = space.call_function(space.w_list, w_dictview)
- w_repr = space.repr(w_seq)
- return space.wrap("%s(%s)" % (space.type(w_dictview).getname(space),
- space.str_w(w_repr)))
+ seq_repr = space.unicode_w(space.repr(w_seq))
+ return space.wrap(u"%s(%s)" % (typename, seq_repr))
repr__DictViewItems = repr__DictViewKeys
repr__DictViewValues = repr__DictViewKeys
diff --git a/pypy/objspace/std/test/test_dictmultiobject.py
b/pypy/objspace/std/test/test_dictmultiobject.py
--- a/pypy/objspace/std/test/test_dictmultiobject.py
+++ b/pypy/objspace/std/test/test_dictmultiobject.py
@@ -1,3 +1,4 @@
+# encoding: utf-8
import py
import sys
from pypy.interpreter.error import OperationError
@@ -719,6 +720,8 @@
assert isinstance(r, str)
assert (r == "dict_values(['ABC', 10])" or
r == "dict_values([10, 'ABC'])")
+ d = {'日本': '日本国'}
+ assert repr(d.items()) == "dict_items([('日本',
'日本国')])"
def test_keys_set_operations(self):
d1 = {'a': 1, 'b': 2}
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit