Issue 31881: subprocess.returncode not set depending on arguments to subprocess.run
If subprocess.run is called with a single string, say:
completed_ps = subprocess.run('mpirun -np 4 myexe.x moreargs', shell=True)
and 'myexe.x moreargs' fails with a returncode of 1, then 'completed_ps.returncode' is None. However, if we split the args with shlex, we obtain the desired result, which is a returncode of 1:
import shlex
args = shlex.split('mpirun -np 4 myexe.x moreargs')
completed_ps = subprocess.run(args)
# now completed_ps.returncode = 1 if myexe.x moreargs fails.
Reproduced on Mac, Ubuntu 17.04, Python 3.6.1 and Python 3.6.3.