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 msekletar
Recipients msekletar
Date 2017-09-13.12:25:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1505305550.33.0.881104489386.issue31450@psf.upfronthosting.co.za>
In-reply-to
Content
Issue
-----
Documentation of subprocess module claims that exceptions raised in child process will be re-raised in the parent process and will have child_traceback attribute set [1]. At least on Fedora Rawhide with python-3.6.2 this is not the case.


Reproducer
----------
$ cat preexec-exception.py
#!/usr/bin/env python3

import subprocess

class PreExecCallback:
    def __call__(self):
        raise Exception()

if __name__ == "__main__":
    p = PreExecCallback()

    try:
        subprocess.Popen(['/bin/echo', 'foobar'], preexec_fn=p)
    except subprocess.SubprocessError as e:
        if not hasattr(e, 'child_traceback'):
            print('BUG: Exception happened in child, but exception object does not have child_traceback attribute')

Actual result
-------------
$ ./preexec-exception.py 
BUG: Exception happened in child, but exception object does not have child_traceback attribute

Expected result
---------------
No output, because child_traceback attribute is present

Additional info
---------------
I happened to notice this while working with pre-exec callbacks. However, according to https://stackoverflow.com/questions/38433837/subprocess-child-traceback this seems to be the generic problem.

[1] https://docs.python.org/3/library/subprocess.html#exceptions
History
Date User Action Args
2017-09-13 12:25:50msekletarsetrecipients: + msekletar
2017-09-13 12:25:50msekletarsetmessageid: <1505305550.33.0.881104489386.issue31450@psf.upfronthosting.co.za>
2017-09-13 12:25:50msekletarlinkissue31450 messages
2017-09-13 12:25:50msekletarcreate