Skip to content

Commit

Permalink
pythongh-106812: Fix two tiny bugs in analysis.py (python#107649)
Browse files Browse the repository at this point in the history
This fixes two tiny defects in analysis.py that I didn't catch on time in python#107564:

- `get_var_names` in `check_macro_consistency` should skip `UNUSED` names.
- Fix an occurrence of `is UNUSED` (should be `==`).
  • Loading branch information
gvanrossum authored Aug 5, 2023
1 parent 4e6fac7 commit 85e5b1f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Tools/cases_generator/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ def check_macro_consistency(self, mac: MacroInstruction) -> None:
def get_var_names(instr: Instruction) -> dict[str, StackEffect]:
vars: dict[str, StackEffect] = {}
for eff in instr.input_effects + instr.output_effects:
if eff.name == UNUSED:
continue
if eff.name in vars:
if vars[eff.name] != eff:
self.error(
Expand Down Expand Up @@ -335,7 +337,7 @@ def get_var_names(instr: Instruction) -> dict[str, StackEffect]:
copies: list[tuple[StackEffect, StackEffect]] = []
while pushes and pops and pushes[-1] == pops[0]:
src, dst = pushes.pop(), pops.pop(0)
if src.name == dst.name or dst.name is UNUSED:
if src.name == dst.name or dst.name == UNUSED:
continue
copies.append((src, dst))
reads = set(copy[0].name for copy in copies)
Expand Down

0 comments on commit 85e5b1f

Please sign in to comment.