Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r90258:90917511788e
Date: 2017-02-21 13:31 +0100
http://bitbucket.org/pypy/pypy/changeset/90917511788e/

Log:    Use fsencode_w() instead of str0 at a few more places (this is
        really a bug fix)

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
@@ -857,18 +857,20 @@
         except OSError as e:
             raise wrap_oserror(space, e)
 
-@unwrap_spec(mode=int, path='str0')
-def spawnv(space, mode, path, w_args):
-    args = [space.str0_w(w_arg) for w_arg in space.unpackiterable(w_args)]
+@unwrap_spec(mode=int)
+def spawnv(space, mode, w_path, w_args):
+    path = fsencode_w(space, w_path)
+    args = [fsencode_w(space, w_arg) for w_arg in space.unpackiterable(w_args)]
     try:
         ret = os.spawnv(mode, path, args)
     except OSError as e:
         raise wrap_oserror(space, e)
     return space.newint(ret)
 
-@unwrap_spec(mode=int, path='str0')
-def spawnve(space, mode, path, w_args, w_env):
-    args = [space.str0_w(w_arg) for w_arg in space.unpackiterable(w_args)]
+@unwrap_spec(mode=int)
+def spawnve(space, mode, w_path, w_args, w_env):
+    path = fsencode_w(space, w_path)
+    args = [fsencode_w(space, w_arg) for w_arg in space.unpackiterable(w_args)]
     env = _env2interp(space, w_env)
     try:
         ret = os.spawnve(mode, path, args, env)
@@ -967,12 +969,12 @@
     except OSError as e:
         raise wrap_oserror(space, e)
 
-@unwrap_spec(path='str0')
-def chroot(space, path):
+def chroot(space, w_path):
     """ chroot(path)
 
     Change root directory to path.
     """
+    path = fsencode_w(space, w_path)
     try:
         os.chroot(path)
     except OSError as e:
@@ -1257,8 +1259,8 @@
         raise wrap_oserror(space, e)
     return space.newint(res)
 
-@unwrap_spec(path='str0')
-def pathconf(space, path, w_name):
+def pathconf(space, w_path, w_name):
+    path = fsencode_w(space, w_path)
     num = confname_w(space, w_name, os.pathconf_names)
     try:
         res = os.pathconf(path, num)
@@ -1274,18 +1276,20 @@
         raise wrap_oserror(space, e)
     return space.newtext(res)
 
-@unwrap_spec(path='str0', uid=c_uid_t, gid=c_gid_t)
-def chown(space, path, uid, gid):
+@unwrap_spec(uid=c_uid_t, gid=c_gid_t)
+def chown(space, w_path, uid, gid):
     """Change the owner and group id of path to the numeric uid and gid."""
+    path = fsencode_w(space, w_path)
     try:
         os.chown(path, uid, gid)
     except OSError as e:
         raise wrap_oserror(space, e, path)
 
-@unwrap_spec(path='str0', uid=c_uid_t, gid=c_gid_t)
-def lchown(space, path, uid, gid):
+@unwrap_spec(uid=c_uid_t, gid=c_gid_t)
+def lchown(space, w_path, uid, gid):
     """Change the owner and group id of path to the numeric uid and gid.
 This function will not follow symbolic links."""
+    path = fsencode_w(space, w_path)
     try:
         os.lchown(path, uid, gid)
     except OSError as e:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to