[New-bugs-announce] [issue31881] subprocess.returncode not set depending on arguments to subprocess.run

Nick report at bugs.python.org
Thu Oct 26 20:20:33 EDT 2017


New submission from Nick <nathompson7 at protonmail.com>:

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.

----------
messages: 305094
nosy: nthompson
priority: normal
severity: normal
status: open
title: subprocess.returncode not set depending on arguments to subprocess.run
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31881>
_______________________________________


More information about the New-bugs-announce mailing list