This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Ben Kane
Recipients Ben Kane, docs@python
Date 2016-05-29.19:15:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464549329.65.0.961898669229.issue27155@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-05-29 19:15:29Ben Kanesetrecipients: + Ben Kane, docs@python
2016-05-29 19:15:29Ben Kanesetmessageid: <1464549329.65.0.961898669229.issue27155@psf.upfronthosting.co.za>
2016-05-29 19:15:29Ben Kanelinkissue27155 messages
2016-05-29 19:15:29Ben Kanecreate