summaryrefslogtreecommitdiff
path: root/coverage
diff options
context:
space:
mode:
authorAndrew Hoos <andrewjhoos@gmail.com>2016-11-29 08:07:05 -0800
committerAndrew Hoos <andrewjhoos@gmail.com>2016-11-29 08:07:05 -0800
commit27a52632dfb7cddc24506862383c406d31362beb (patch)
tree5002d1ad37b8f311e2d32834c0c7fb9e9cc942a9 /coverage
parenta834bb295a262bd9ff172748afa9c2a75a1d5a52 (diff)
downloadpython-coveragepy-27a52632dfb7cddc24506862383c406d31362beb.tar.gz
Update handling of sys.excepthook to only call custom excepthooks and re-raise exceptions
Diffstat (limited to 'coverage')
-rw-r--r--coverage/execfile.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/coverage/execfile.py b/coverage/execfile.py
index 39d17e9..8ff3877 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