[issue42693] "if 0:" lines are traced; they didn't use to be

Mark Shannon report at bugs.python.org
Tue Dec 22 11:14:23 EST 2020


Mark Shannon <mark at hotpy.org> added the comment:

Ned, I agree that up until 3.9, it is wasn't that simple.
But from 3.10 onward, it should be that simple.
That's the point of PEP 626.

If a transformation changes observable behavior within the scope of language specification, then it is not an optimization but a bug.

Up to 3.9, the language did not specify the behavior of sys.settrace w.r.t. line numbers, so coverage.py had to second guess what the bytecode optimizer was doing. 

In 3.10 onwards, the behavior of sys.settrace w.r.t. line numbers is part of the language spec. The optimizer cannot change it, and coverage.py should not need care what the optimizer does.

If you can observe the effect of the optimizer, w.r.t. line numbers, then it's a bug.

(According to that definition, there are still bugs in the optimizer relating to jumps-to-jumps. I plan to fix them)

----------

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


More information about the Python-bugs-list mailing list