[Python-checkins] Revert "bpo-35537: subprocess can now use os.posix_spawnp (GH-11579)" (GH-11582)

Victor Stinner webhook-mailer at python.org
Wed Jan 16 17:38:12 EST 2019


https://github.com/python/cpython/commit/8c349565e8a442e17f1a954d1a9996847749d778
commit: 8c349565e8a442e17f1a954d1a9996847749d778
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2019-01-16T23:38:06+01:00
summary:

Revert "bpo-35537: subprocess can now use os.posix_spawnp (GH-11579)" (GH-11582)

This reverts commit 07858894689047c77f9c12ddc061d30681368d19.

files:
M Doc/whatsnew/3.8.rst
M Lib/subprocess.py
M Lib/test/pythoninfo.py

diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index 05fb4ffe03bb..053fe902c481 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -281,7 +281,8 @@ Optimizations
 
   * *close_fds* is false;
   * *preexec_fn*, *pass_fds*, *cwd*, *stdin*, *stdout*, *stderr* and
-    *start_new_session* parameters are not set.
+    *start_new_session* parameters are not set;
+  * the *executable* path contains a directory.
 
 * :func:`shutil.copyfile`, :func:`shutil.copy`, :func:`shutil.copy2`,
   :func:`shutil.copytree` and :func:`shutil.move` use platform-specific
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index d63cf2050634..b94575b8401e 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -655,7 +655,6 @@ def _use_posix_spawn():
 
 
 _USE_POSIX_SPAWN = _use_posix_spawn()
-_HAVE_POSIX_SPAWNP = hasattr(os, 'posix_spawnp')
 
 
 class Popen(object):
@@ -1443,10 +1442,7 @@ def _get_handles(self, stdin, stdout, stderr):
 
 
         def _posix_spawn(self, args, executable, env, restore_signals):
-            """Execute program using os.posix_spawnp().
-
-            Or use os.posix_spawn() if os.posix_spawnp() is not available.
-            """
+            """Execute program using os.posix_spawn()."""
             if env is None:
                 env = os.environ
 
@@ -1460,10 +1456,7 @@ def _posix_spawn(self, args, executable, env, restore_signals):
                         sigset.append(signum)
                 kwargs['setsigdef'] = sigset
 
-            if _HAVE_POSIX_SPAWNP:
-                self.pid = os.posix_spawnp(executable, args, env, **kwargs)
-            else:
-                self.pid = os.posix_spawn(executable, args, env, **kwargs)
+            self.pid = os.posix_spawn(executable, args, env, **kwargs)
 
         def _execute_child(self, args, executable, preexec_fn, close_fds,
                            pass_fds, cwd, env,
@@ -1491,7 +1484,7 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
                 executable = args[0]
 
             if (_USE_POSIX_SPAWN
-                    and (_HAVE_POSIX_SPAWNP or os.path.dirname(executable))
+                    and os.path.dirname(executable)
                     and preexec_fn is None
                     and not close_fds
                     and not pass_fds
diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py
index 93d87be41588..7e94a31cecea 100644
--- a/Lib/test/pythoninfo.py
+++ b/Lib/test/pythoninfo.py
@@ -612,8 +612,7 @@ def collect_get_config(info_add):
 
 def collect_subprocess(info_add):
     import subprocess
-    attrs = ('_USE_POSIX_SPAWN', '_HAVE_POSIX_SPAWNP')
-    copy_attributes(info_add, subprocess, 'subprocess.%s', attrs)
+    copy_attributes(info_add, subprocess, 'subprocess.%s', ('_USE_POSIX_SPAWN',))
 
 
 def collect_info(info):



More information about the Python-checkins mailing list