From ff22f3bda01cde32b8dab56997afd02445c1c583 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 28 Oct 2014 09:24:33 -0400 Subject: Fix a weird PyPy3 problem with a weird PyPy3 fix. --- coverage/execfile.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'coverage') diff --git a/coverage/execfile.py b/coverage/execfile.py index b7877b6a..82cc2217 100644 --- a/coverage/execfile.py +++ b/coverage/execfile.py @@ -138,6 +138,13 @@ def run_python_file(filename, args, package=None): # so that the coverage.py code doesn't appear in the final printed # traceback. typ, err, tb = sys.exc_info() + + # PyPy3 weirdness. If I don't access __context__, then somehow it + # is non-None when the exception is reported at the upper layer, + # 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) + raise ExceptionDuringRun(typ, err, tb.tb_next) finally: # Restore the old __main__ -- cgit v1.2.1