[New-bugs-announce] [issue34799] When function in tracing returns None, tracing continues.

Fabio Zadrozny report at bugs.python.org
Tue Sep 25 11:06:20 EDT 2018


New submission from Fabio Zadrozny <fabioz at users.sourceforge.net>:

https://docs.python.org/3/library/sys.html#sys.settrace explicitly states:

The local trace function should return a reference to itself (or to another function for further tracing in that scope), or None to turn off tracing in that scope.

Yet, it seems this happens only on the return of a 'call'. If None is returned in a 'line' event, apparently the previous tracing function is reused (but if a new function is returned, the new function is used properly).

I'm attaching a test case which shows the issue. I've tested on 2.7, 3.6 and 3.7 and this issue is present on all.

If I set frame.f_trace = None before returning it seems to work though (so, I think that either this behavior should be fixed or the docs should be updated to reflect that).

----------
files: issue_in_tracing_func.py
messages: 326360
nosy: fabioz
priority: normal
severity: normal
status: open
title: When function in tracing returns None, tracing continues.
type: behavior
versions: Python 2.7, Python 3.6, Python 3.7
Added file: https://bugs.python.org/file47822/issue_in_tracing_func.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34799>
_______________________________________


More information about the New-bugs-announce mailing list