[pypy-commit] pypy space-newtext: try to fix two win issues

cfbolz pypy.commits at gmail.com
Tue Dec 6 06:42:49 EST 2016


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: space-newtext
Changeset: r88898:47cdbd271ed9
Date: 2016-12-06 12:06 +0100
http://bitbucket.org/pypy/pypy/changeset/47cdbd271ed9/

Log:	try to fix two win issues

diff --git a/pypy/module/_winreg/interp_winreg.py b/pypy/module/_winreg/interp_winreg.py
--- a/pypy/module/_winreg/interp_winreg.py
+++ b/pypy/module/_winreg/interp_winreg.py
@@ -701,7 +701,7 @@
 def ExpandEnvironmentStrings(space, source):
     "string = ExpandEnvironmentStrings(string) - Expand environment vars."
     try:
-        return space.newtext(rwinreg.ExpandEnvironmentStrings(source))
+        return space.newunicode(rwinreg.ExpandEnvironmentStrings(source))
     except WindowsError as e:
         raise wrap_windowserror(space, e)
 
diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -580,15 +580,18 @@
             len_result = len(result)
             result_w = [None] * len_result
             for i in range(len_result):
-                w_bytes = space.newtext(result[i])
-                try:
-                    result_w[i] = space.call_method(w_bytes,
-                                                    "decode", w_fs_encoding)
-                except OperationError as e:
-                    # fall back to the original byte string
-                    if e.async(space):
-                        raise
-                    result_w[i] = w_bytes
+                if type(result[i]) is unicode:
+                    result_w[i] = space.newunicode(result[i])
+                else:
+                    w_bytes = space.newtext(result[i])
+                    try:
+                        result_w[i] = space.call_method(w_bytes,
+                                                        "decode", w_fs_encoding)
+                    except OperationError as e:
+                        # fall back to the original byte string
+                        if e.async(space):
+                            raise
+                        result_w[i] = w_bytes
             return space.newlist(result_w)
         else:
             dirname = space.str0_w(w_dirname)


More information about the pypy-commit mailing list