[New-bugs-announce] [issue27155] '-' sign typo in example

Ben Kane report at bugs.python.org
Sun May 29 15:15:29 EDT 2016


New submission from Ben Kane:

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.

----------
assignee: docs at python
components: Documentation
messages: 266614
nosy: Ben Kane, docs at python
priority: normal
severity: normal
status: open
title: '-' sign typo in example
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27155>
_______________________________________


More information about the New-bugs-announce mailing list