Ned Batchelder <[email protected]> added the comment:
Thanks, that fixes the original case in this issue.
Here is another problem which seems related enough to append here instead of
opening a new issue:
--- 8< ----------------------------------------------------
import linecache, sys
def trace(frame, event, arg):
lineno = frame.f_lineno
print("{} {}: {}".format(event[:4], lineno, linecache.getline(__file__,
lineno).rstrip()))
return trace
print(sys.version)
sys.settrace(trace)
def b(exc):
print("exc is {!r}".format(exc))
try:
raise Exception(exc)
except Exception as e:
if exc != 'expected':
raise # line 17
q = "removing this line changes the behavior"
r = "is this executed?" # line 19
return
b('expected')
try:
b('unexpected')
except:
pass
--- 8< ----------------------------------------------------
With your fix, it reports that the raise on line 17 is followed by line 19,
which can't be right:
3.9.0a2+ (heads/pr/17737:f2545467fa, Dec 29 2019, 15:38:57)
[Clang 10.0.0 (clang-1000.10.44.4)]
call 11: def b(exc):
line 12: print("exc is {!r}".format(exc))
exc is 'expected'
line 13: try:
line 14: raise Exception(exc)
exce 14: raise Exception(exc)
line 15: except Exception as e:
line 16: if exc != 'expected':
line 18: q = "removing this line changes the behavior"
line 19: r = "is this executed?"
line 20: return
retu 20: return
call 11: def b(exc):
line 12: print("exc is {!r}".format(exc))
exc is 'unexpected'
line 13: try:
line 14: raise Exception(exc)
exce 14: raise Exception(exc)
line 15: except Exception as e:
line 16: if exc != 'expected':
line 17: raise
line 19: r = "is this executed?"
retu 19: r = "is this executed?"
Python 3.8 reported this:
3.8.1 (default, Dec 19 2019, 08:38:38)
[Clang 10.0.0 (clang-1000.10.44.4)]
call 11: def b(exc):
line 12: print("exc is {!r}".format(exc))
exc is 'expected'
line 13: try:
line 14: raise Exception(exc)
exce 14: raise Exception(exc)
line 15: except Exception as e:
line 16: if exc != 'expected':
line 18: q = "removing this line changes the behavior"
line 19: r = "is this executed?"
line 20: return
retu 20: return
call 11: def b(exc):
line 12: print("exc is {!r}".format(exc))
exc is 'unexpected'
line 13: try:
line 14: raise Exception(exc)
exce 14: raise Exception(exc)
line 15: except Exception as e:
line 16: if exc != 'expected':
line 17: raise
retu 17: raise
----------
status: closed -> open
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue39114>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com