New submission from Michal Sekletar:
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
----------
components: Library (Lib)
messages: 302064
nosy: msekletar
priority: normal
severity: normal
status: open
title: Subprocess exceptions re-raised in parent process do not have
child_traceback attribute
type: behavior
versions: Python 3.6
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue31450>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com