Message302064
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 |
|
Date |
User |
Action |
Args |
2017-09-13 12:25:50 | msekletar | set | recipients:
+ msekletar |
2017-09-13 12:25:50 | msekletar | set | messageid: <1505305550.33.0.881104489386.issue31450@psf.upfronthosting.co.za> |
2017-09-13 12:25:50 | msekletar | link | issue31450 messages |
2017-09-13 12:25:50 | msekletar | create | |
|