[New-bugs-announce] [issue44816] Folded constants do not trace correctly.
Brandt Bucher
report at bugs.python.org
Mon Aug 2 19:28:31 EDT 2021
New submission from Brandt Bucher <brandtbucher at gmail.com>:
PEP 626 says that "all expressions and parts of expressions are considered to be executable code" for the purposes of tracing. However, folding constants at compile-time can lose or change tracing events.
For example, these expressions (which can't be folded) generate events for two lines each:
[ # <--
None # <--
]
( # <--
foo, # <--
)
(
1 # <--
/
0 # <--
)
(
1 # <--
/
bar # <--
)
While these (which are folded) only generate events for one line each:
( # <--
None,
)
( # <--
1
/
42
)
Note that for the binary operation, a completely different line is traced in the optimized version.
We should correctly generate events for lines which are "folded away". This *might* mean refusing to fold nodes in the AST optimizer if they span multiple lines, or including some sort of additional line-coverage metadata on the new Constant nodes to fill NOPs as appropriate (which I personally prefer).
----------
components: Interpreter Core
messages: 398810
nosy: Mark.Shannon, brandtbucher
priority: normal
severity: normal
status: open
title: Folded constants do not trace correctly.
type: behavior
versions: Python 3.11
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44816>
_______________________________________
More information about the New-bugs-announce
mailing list