New submission from Brandt Bucher <[email protected]>:
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 <[email protected]>
<https://bugs.python.org/issue44816>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com