[issue42286] f_trace gets call on different lines each loop

Cornelius Krupp report at bugs.python.org
Sat Nov 7 17:19:53 EST 2020


New submission from Cornelius Krupp <trampchamp at hotmail.de>:

When using a local trace function, sometimes the line event is issued at the wrong time. As can be seen from the example file `f_trace_wrong_line.py`, each loop iteration we get either 24 or 23, apparently in a fixed rhythm.

While this might seem harmless, it appears that the line event for 23 (In this example) is issued at a time where the state of the stack is not valid to switch line. I noticed this because I wanted to implement a context manager that skips to a specific line, but this broken with mysterious error message `TypeError: 'NoneType' object is not callable` which I think is caused by the `with`-line not being fully executed and the stack still having the return value of `__enter__` on it.



Here the intro line of the interpreter:

Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32

----------
components: Interpreter Core
files: f_trace_wrong_line.py
messages: 380527
nosy: trampchamp
priority: normal
severity: normal
status: open
title: f_trace gets call on different lines each loop
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file49580/f_trace_wrong_line.py

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


More information about the Python-bugs-list mailing list