diff options
author | Andrew Hoos <andrewjhoos@gmail.com> | 2016-11-29 08:07:05 -0800 |
---|---|---|
committer | Andrew Hoos <andrewjhoos@gmail.com> | 2016-11-29 08:07:05 -0800 |
commit | 9379e9870e64e49cdbaf80df6b2d9c5e932048bd (patch) | |
tree | 8ec89300ac570eeb94d7828a19a9e3e83d0c6b5e /coverage/execfile.py | |
parent | ce23a42661b1b8f28e31255534c55047a004ecab (diff) | |
download | python-coveragepy-git-9379e9870e64e49cdbaf80df6b2d9c5e932048bd.tar.gz |
Update handling of sys.excepthook to only call custom excepthooks and re-raise exceptions
Diffstat (limited to 'coverage/execfile.py')
-rw-r--r-- | coverage/execfile.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/coverage/execfile.py b/coverage/execfile.py index 39d17e9f..8ff38776 100644 --- a/coverage/execfile.py +++ b/coverage/execfile.py @@ -192,7 +192,12 @@ def run_python_file(filename, args, package=None, modulename=None, path0=None): # and a nested exception is shown to the user. This getattr fixes # it somehow? https://bitbucket.org/pypy/pypy/issue/1903 getattr(err, '__context__', None) - sys.excepthook(typ, err, tb.tb_next) + + # call a custom user excepthook if it is provided + if sys.excepthook is not sys.__excepthook__: + sys.excepthook(typ, err, tb.tb_next) + raise ExceptionDuringRun(typ, err, tb.tb_next) + finally: # Restore the old __main__, argv, and path. sys.modules['__main__'] = old_main_mod |