finally blocks are duplicated by the compiler unnecessarily #92619
Labels
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
performance
Performance or resource usage
type-bug
An unexpected behavior, bug, or error
Bug report
Input:
Output:
Lines 28-36 are exactly the same as lines 38-46. The reason they got duplicated is because of duplicate_exits_without_lineno, which makes copies of exit blocks that don't have a line number, and can be reached from more than one place (because line numbers are static).
However, the check is "is it an exit block and does the first instruction have a lineno". In our case, the first instruction is a virtual POP_BLOCK (which eventually becomes a NOP). The virtual instruction doesn't have a line number, but the following instructions (the finally body) do. Note that what we really care about is whether the last instruction has a line number.
The text was updated successfully, but these errors were encountered: