Changeset 603 for python


Ignore:
Timestamp:
Dec 11, 2015, 1:26:45 AM (10 years ago)
Author:
dmik
Message:

python: Use configured SHELL in subprocess module.

Use the shell that was configured when building python whe
supbropcess.Popen(shell=True) is requested instead of the
hardcoded '/bin/sh' value which might be not there.

Closes #141.

Location:
python/trunk/Lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk/Lib/popen2.py

    r10 r603  
    1212warnings.warn("The popen2 module is deprecated.  Use the subprocess module.",
    1313              DeprecationWarning, stacklevel=2)
     14
     15import sysconfig
     16SHELL = sysconfig.get_config_var('SHELL') or '/bin/sh'
    1417
    1518__all__ = ["popen2", "popen3", "popen4"]
     
    8285    def _run_child(self, cmd):
    8386        if isinstance(cmd, basestring):
    84             cmd = ['/bin/sh', '-c', cmd]
     87            cmd = [SHELL, '-c', cmd]
    8588        os.closerange(3, MAXFD)
    8689        try:
  • python/trunk/Lib/subprocess.py

    r391 r603  
    396396import signal
    397397import errno
     398
     399import sysconfig
     400SHELL = sysconfig.get_config_var('SHELL') or '/bin/sh'
    398401
    399402# Exception classes used by this module.
     
    11981201
    11991202            if shell:
    1200                 args = ["/bin/sh", "-c"] + args
     1203                args = [SHELL, "-c"] + args
    12011204                if executable:
    12021205                    args[0] = executable
Note: See TracChangeset for help on using the changeset viewer.