Message266614
On page https://docs.python.org/3/library/subprocess.html#replacing-os-system
it looks like the code in the realistic example has a spurious '-' sign.
The line:
print("Child was terminated by signal", -retcode, file=sys.stderr)
shouldn't have the minus sign negating the retcode:
print("Child was terminated by signal", retcode, file=sys.stderr)
Full code in the example:
try:
retcode = call("mycmd" + " myarg", shell=True)
if retcode < 0:
print("Child was terminated by signal", -retcode, file=sys.stderr)
else:
print("Child returned", retcode, file=sys.stderr)
except OSError as e:
print("Execution failed:", e, file=sys.stderr)
should be:
try:
retcode = call("mycmd" + " myarg", shell=True)
if retcode < 0:
print("Child was terminated by signal", retcode, file=sys.stderr)
else:
print("Child returned", retcode, file=sys.stderr)
except OSError as e:
print("Execution failed:", e, file=sys.stderr)
Thanks, and apologies if I erred somewhere in this report. |
|
Date |
User |
Action |
Args |
2016-05-29 19:15:29 | Ben Kane | set | recipients:
+ Ben Kane, docs@python |
2016-05-29 19:15:29 | Ben Kane | set | messageid: <1464549329.65.0.961898669229.issue27155@psf.upfronthosting.co.za> |
2016-05-29 19:15:29 | Ben Kane | link | issue27155 messages |
2016-05-29 19:15:29 | Ben Kane | create | |
|