]> granicus.if.org Git - python/commitdiff
Issue #16255: subrocess.Popen uses /system/bin/sh on Android as the shell,
authorXavier de Gaye <xdegaye@users.sourceforge.net>
Tue, 13 Dec 2016 15:32:21 +0000 (16:32 +0100)
committerXavier de Gaye <xdegaye@users.sourceforge.net>
Tue, 13 Dec 2016 15:32:21 +0000 (16:32 +0100)
instead of /bin/sh.

Lib/subprocess.py
Misc/NEWS

index c40f0179eef9970974978e41e96f53f68b69e360..809e59f5eb7d0a05efc278d2a06edb947ec2d501 100644 (file)
@@ -1204,7 +1204,10 @@ class Popen(object):
                 args = list(args)
 
             if shell:
-                args = ["/bin/sh", "-c"] + args
+                # On Android the default shell is at '/system/bin/sh'.
+                unix_shell = ('/system/bin/sh' if
+                          hasattr(sys, 'getandroidapilevel') else '/bin/sh')
+                args = [unix_shell, "-c"] + args
                 if executable:
                     args[0] = executable
 
index fe9dc95890804f3680fd6993e5380b1d7625ebe5..a06e3cb788e278d259034c2a91b7f5a8283d33ae 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -177,6 +177,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #16255: subrocess.Popen uses /system/bin/sh on Android as the shell,
+  instead of /bin/sh.
+
 - Issue #28779: multiprocessing.set_forkserver_preload() would crash the
   forkserver process if a preloaded module instantiated some
   multiprocessing objects such as locks.