pypy3.9-v7.3.8rc1 traces an unexecuted function after a re-raise
Using 3.9.10 (pypy3.9-v7.3.8rc1), a re-raise also traces an unexecuted statement after the raise.
Reproduction:
import linecache, sys
def trace(frame, event, arg):
# The weird globals here is to avoid a NameError on shutdown...
if frame.f_code.co_filename == globals().get("__file__"):
lineno = frame.f_lineno
line = linecache.getline(__file__, lineno).rstrip()
print("{} {}: {}".format(event[:4], lineno, line))
return trace
print(sys.version)
sys.settrace(trace)
def b(reraise):
try:
raise Exception(exc)
except Exception as e:
if reraise:
raise
print("after raise") # Not run
try:
b(True)
except:
pass
With 3.8, the trace is correct:
$ /usr/local/pypy/pypy3.8-v7.3.8rc1-osx64/bin/pypy3 pp39.py
3.8.12 (67f1b98040bad2f1241e4e1ebde6051a505f628a, Jan 26 2022, 14:44:12)
[PyPy 7.3.8 with GCC Apple LLVM 13.0.0 (clang-1300.0.29.30)]
call 14: def b(reraise):
line 15: try:
line 16: raise Exception(exc)
exce 16: raise Exception(exc)
line 17: except Exception as e:
line 18: if reraise:
line 19: raise
retu 19: raise
With 3.9, the print statement is traced, even though it is not run:
$ /usr/local/pypy/pypy3.9-v7.3.8rc1-osx64/bin/pypy3 pp39.py
3.9.10 (307e102d7222131fee14073e8856df773627186c, Jan 24 2022, 18:24:25)
[PyPy 7.3.8 with GCC Apple LLVM 13.0.0 (clang-1300.0.29.30)]
call 14: def b(reraise):
line 15: try:
line 16: raise Exception(exc)
exce 16: raise Exception(exc)
line 17: except Exception as e:
line 18: if reraise:
line 19: raise
line 20: print("after raise") # Not run
retu 20: print("after raise") # Not run