Skip to content

Commit 8c34956

Browse files
authored
Revert "bpo-35537: subprocess can now use os.posix_spawnp (GH-11579)" (GH-11582)
This reverts commit 0785889.
1 parent 0785889 commit 8c34956

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

Doc/whatsnew/3.8.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ Optimizations
281281

282282
* *close_fds* is false;
283283
* *preexec_fn*, *pass_fds*, *cwd*, *stdin*, *stdout*, *stderr* and
284-
*start_new_session* parameters are not set.
284+
*start_new_session* parameters are not set;
285+
* the *executable* path contains a directory.
285286

286287
* :func:`shutil.copyfile`, :func:`shutil.copy`, :func:`shutil.copy2`,
287288
:func:`shutil.copytree` and :func:`shutil.move` use platform-specific

Lib/subprocess.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,6 @@ def _use_posix_spawn():
655655

656656

657657
_USE_POSIX_SPAWN = _use_posix_spawn()
658-
_HAVE_POSIX_SPAWNP = hasattr(os, 'posix_spawnp')
659658

660659

661660
class Popen(object):
@@ -1443,10 +1442,7 @@ def _get_handles(self, stdin, stdout, stderr):
14431442

14441443

14451444
def _posix_spawn(self, args, executable, env, restore_signals):
1446-
"""Execute program using os.posix_spawnp().
1447-
1448-
Or use os.posix_spawn() if os.posix_spawnp() is not available.
1449-
"""
1445+
"""Execute program using os.posix_spawn()."""
14501446
if env is None:
14511447
env = os.environ
14521448

@@ -1460,10 +1456,7 @@ def _posix_spawn(self, args, executable, env, restore_signals):
14601456
sigset.append(signum)
14611457
kwargs['setsigdef'] = sigset
14621458

1463-
if _HAVE_POSIX_SPAWNP:
1464-
self.pid = os.posix_spawnp(executable, args, env, **kwargs)
1465-
else:
1466-
self.pid = os.posix_spawn(executable, args, env, **kwargs)
1459+
self.pid = os.posix_spawn(executable, args, env, **kwargs)
14671460

14681461
def _execute_child(self, args, executable, preexec_fn, close_fds,
14691462
pass_fds, cwd, env,
@@ -1491,7 +1484,7 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
14911484
executable = args[0]
14921485

14931486
if (_USE_POSIX_SPAWN
1494-
and (_HAVE_POSIX_SPAWNP or os.path.dirname(executable))
1487+
and os.path.dirname(executable)
14951488
and preexec_fn is None
14961489
and not close_fds
14971490
and not pass_fds

Lib/test/pythoninfo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,7 @@ def collect_get_config(info_add):
612612

613613
def collect_subprocess(info_add):
614614
import subprocess
615-
attrs = ('_USE_POSIX_SPAWN', '_HAVE_POSIX_SPAWNP')
616-
copy_attributes(info_add, subprocess, 'subprocess.%s', attrs)
615+
copy_attributes(info_add, subprocess, 'subprocess.%s', ('_USE_POSIX_SPAWN',))
617616

618617

619618
def collect_info(info):

0 commit comments

Comments
 (0)