Inconsistent locations for conditional branches in while statements #122821
Copy link
Copy link
Closed
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Reported here: #122762 (comment)
The locations for branches in while statements are not consistent. The first iteration shows different locations from the second and later iterations.
I've not check earlier versions, but this could be an issue for 3.12 as well.
CPython versions tested on:
3.13, CPython main branch
Operating systems tested on:
No response
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
markshannon commentedon Aug 8, 2024
Here's my hypothesis:
This is an artifact of compiling
while cond: bodyas:and the assembler converting condition backwards jumps from
if cond goto targettoSo we end up with:
When
condisTrue, the first branch jumps fromcondtobody, but the second branch jumps fromcondtocond.Compiling
while cond: bodyas:should fix this.
GH-122821: Simplify compilation of while statements to ensure consist…
pythonGH-122821: Simplify compilation of while statements to ensure c…