Message359037
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 |
|
Date |
User |
Action |
Args |
2019-12-30 12:39:54 | nedbat | set | recipients:
+ nedbat, Mark.Shannon, serhiy.storchaka, pablogsal, xtreak |
2019-12-30 12:39:54 | nedbat | set | messageid: <1577709594.35.0.153744629745.issue39114@roundup.psfhosted.org> |
2019-12-30 12:39:54 | nedbat | link | issue39114 messages |
2019-12-30 12:39:54 | nedbat | create | |
|