Author: Armin Rigo <[email protected]>
Branch: py3.5-newtext
Changeset: r90151:966d42ca0e4e
Date: 2017-02-15 13:57 +0100
http://bitbucket.org/pypy/pypy/changeset/966d42ca0e4e/

Log:    improve space.newlist_text()

diff --git a/pypy/objspace/std/kwargsdict.py b/pypy/objspace/std/kwargsdict.py
--- a/pypy/objspace/std/kwargsdict.py
+++ b/pypy/objspace/std/kwargsdict.py
@@ -115,9 +115,8 @@
             return w_dict.getitem(w_key)
 
     def w_keys(self, w_dict):
-        space = self.space
-        keys = self.unerase(w_dict.dstorage)[0]
-        return space.newlist_unicode([key.decode('utf-8') for key in keys])
+        l = self.unerase(w_dict.dstorage)[0]
+        return self.space.newlist_text(l[:])
 
     def values(self, w_dict):
         return self.unerase(w_dict.dstorage)[1][:] # to make non-resizable
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -304,8 +304,8 @@
         return W_ListObject.newlist_bytes(self, list_s)
 
     def newlist_text(self, list_t):
-        # XXX improve!
-        return self.newlist([self.newtext(t) for t in list_t])
+        return self.newlist_unicode([
+            decode_utf8(self, s, allow_surrogates=True) for s in list_t])
 
     def newlist_unicode(self, list_u):
         return W_ListObject.newlist_unicode(self, list_u)
@@ -356,9 +356,6 @@
     def newtext(self, s):
         return self.newunicode(decode_utf8(self, s, allow_surrogates=True))
 
-    def newtext(self, s):
-        return self.newunicode(decode_utf8(self, s, allow_surrogates=True))
-
     def newtext_or_none(self, s):
         if s is None:
             return self.w_None
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to