[New-bugs-announce] [issue21033] previous trace function still invoked after sys.settrace()

Xavier de Gaye report at bugs.python.org
Sun Mar 23 09:36:13 CET 2014


New submission from Xavier de Gaye:

The following output of settrace.py shows that the Tracer trace function is still called in foo() after the New_tracer trace function has been installed with sys.settrace() from within the trace function itself, and even though f_trace has been set on all the frames of the stack with the new trace function as this is done in bdb.Bdb.set_trace():

sys.settrace(Tracer.trace)
Tracer:line at <module>:30
Tracer:call at foo:23
sys.settrace(New_tracer.trace)
Tracer:line at foo:24
New_tracer:call at bar:27
New_tracer:line at bar:27
New_tracer:return at bar:27
Tracer:line at foo:25
Tracer:return at foo:25
New_tracer:return at <module>:30

Python should not allow to call successfully sys.settrace() when tracing, except for sys.settrace(None).
This does not seem easy to fix without adding some state, as the 'tracing' field in PyThreadState is used for both trace/profile codes.

----------
components: Interpreter Core
files: settrace.py
messages: 214553
nosy: xdegaye
priority: normal
severity: normal
status: open
title: previous trace function still invoked after sys.settrace()
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file34581/settrace.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21033>
_______________________________________


More information about the New-bugs-announce mailing list