This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: When function in tracing returns None, tracing continues.
Type: behavior Stage:
Components: Versions: Python 3.7, Python 3.6, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: fabioz
Priority: normal Keywords:

Created on 2018-09-25 15:06 by fabioz, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
issue_in_tracing_func.py fabioz, 2018-09-25 15:06 Test case showing error.
Messages (1)
msg326360 - (view) Author: Fabio Zadrozny (fabioz) * Date: 2018-09-25 15:06
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).
History
Date User Action Args
2022-04-11 14:59:06adminsetgithub: 78980
2018-09-25 15:06:20fabiozcreate