Issue2540

classification
Title: settrace doesn't notice "with" statements
Type: Severity: normal
Components: Versions: Jython 2.7
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: nedbat
Priority: Keywords:

Created on 2017-01-14.19:30:13 by nedbat, last changed 2017-01-14.19:30:13 by nedbat.

Messages
msg11021 (view) Author: Ned Batchelder (nedbat) Date: 2017-01-14.19:30:13
Similar to #1751, the trace function doesn't report events for "with" statements:

$ cat bug.py
import sys

def tracefunc(frame, event, arg):
    print "Trace", event, frame.f_lineno
    return tracefunc

def do():
    with open("hello.txt", "w") as f:
        f.write("Hello\n")

sys.settrace(tracefunc)
do()

$ python2.7 bug.py
Trace call 7
Trace line 8
Trace line 9
Trace return 9
Trace call 38
Trace call 38

$ jython bug.py
Trace call 7
Trace line 9
Trace return 9
$
History
Date User Action Args
2017-01-14 19:30:14nedbatcreate