Message11025
"with" statements are also overlooked:
import linecache, sys
def tracefunc(frame, event, arg):
lineno = frame.f_lineno
print "Trace", event, lineno, linecache.getline(__file__, lineno).rstrip()
return tracefunc
def do():
x = [ 1 ]
for i in range(2):
try:
x[i]
except IndexError:
break
with open(__file__) as f:
print len(f.read())
sys.settrace(tracefunc)
do()
Produces:
Trace call 8 def do():
Trace line 9 x = [ 1 ]
Trace line 10 for i in range(2):
Trace line 10 for i in range(2):
Trace line 12 x[i]
Trace line 10 for i in range(2):
Trace line 12 x[i]
Trace exception 12 x[i]
Trace line 17 print len(f.read())
397
Trace return 17 print len(f.read()) |
|
Date |
User |
Action |
Args |
2017-01-19 00:26:56 | nedbat | set | messageid: <1484785616.66.0.868906577316.issue1751@psf.upfronthosting.co.za> |
2017-01-19 00:26:56 | nedbat | set | recipients:
+ nedbat, fwierzbicki, zyasoft, geoffbache |
2017-01-19 00:26:56 | nedbat | link | issue1751 messages |
2017-01-19 00:26:56 | nedbat | create | |
|