Skip to content

Commit d836d28

Browse files
authored
pythonGH-131729: Consider in-memory state when merging storage and stack (pythonGH-131773)
1 parent 316938b commit d836d28

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

Python/executor_cases.c.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tools/cases_generator/stack.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ def merge(self, other: "Stack", out: CWriter) -> None:
378378
if self_var.memory_offset is not None:
379379
if self_var.memory_offset != other_var.memory_offset:
380380
raise StackError(f"Mismatched stack depths for {self_var.name}: {self_var.memory_offset} and {other_var.memory_offset}")
381+
elif other_var.memory_offset is None:
382+
self_var.memory_offset = None
381383

382384

383385
def stacks(inst: Instruction | PseudoInstruction) -> Iterator[StackEffect]:
@@ -601,6 +603,11 @@ def merge(self, other: "Storage", out: CWriter) -> None:
601603
if len(self.outputs) != len(other.outputs):
602604
var = self.outputs[0] if len(self.outputs) > len(other.outputs) else other.outputs[0]
603605
raise StackError(f"'{var.name}' is set on some paths, but not all")
606+
for var, other_var in zip(self.outputs, other.outputs):
607+
if var.memory_offset is None:
608+
other_var.memory_offset = None
609+
elif other_var.memory_offset is None:
610+
var.memory_offset = None
604611
self.stack.merge(other.stack, out)
605612
self.sanity_check()
606613

0 commit comments

Comments
 (0)