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.

classification
Title: multiprocessing: SystemExit from child with non-int, non-str arg causes TypeError
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brandjon, jnoller, python-dev, sbt
Priority: normal Keywords:

Created on 2012-01-24 18:08 by brandjon, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg151921 - (view) Author: Jon Brandvein (brandjon) Date: 2012-01-24 18:08
In a child process, raising SystemExit or calling sys.exit with a non-integer, non-string argument value causes a TypeError at Lib/multiprocessing/process.py :: _bootstrap. This is from concatenating the argument with '\n' and writing it to stderr.

Suggested fix: replace
    sys.stderr.write(e.args[0] + '\n')
with
    sys.stderr.write(str(e.args[0]) + '\n')

This problem also occurs when the value is None, but only for raising SystemExit (not calling sys.exit()).
msg151951 - (view) Author: Jon Brandvein (brandjon) Date: 2012-01-25 17:25
Also, as Brett pointed out to me in #13853, bool is a subclass of int, so they should follow the same code path. I suggest replacing

    elif type(e.args[0]) is int:
        exitcode = e.args[0]

with something like

    elif isinstance(e.args[0], int):
        exitcode = e.args[0]

which assumes that a subtype of int is convertible to int.
msg162494 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-06-07 19:42
New changeset 4346cba353b4 by Richard Oudkerk in branch '3.2':
Issue #13854: Properly handle non-integer, non-string arg to SystemExit
http://hg.python.org/cpython/rev/4346cba353b4

New changeset 3585cb1388f2 by Richard Oudkerk in branch 'default':
Merge fixes for #13854 and #12157.
http://hg.python.org/cpython/rev/3585cb1388f2

New changeset da5b370f41a1 by Richard Oudkerk in branch '2.7':
Issue #13854: Properly handle non-integer, non-string arg to SystemExit
http://hg.python.org/cpython/rev/da5b370f41a1
History
Date User Action Args
2022-04-11 14:57:26adminsetgithub: 58062
2012-06-07 22:18:42sbtsetstatus: open -> closed
resolution: fixed
stage: resolved
2012-06-07 19:42:03python-devsetnosy: + python-dev
messages: + msg162494
2012-06-06 12:24:48sbtsetnosy: + sbt
2012-01-25 17:25:47brandjonsetmessages: + msg151951
2012-01-24 18:08:45brandjoncreate