]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106812: Fix two tiny bugs in analysis.py (#107649)
authorGuido van Rossum <guido@python.org>
Sat, 5 Aug 2023 04:50:36 +0000 (21:50 -0700)
committerGitHub <noreply@github.com>
Sat, 5 Aug 2023 04:50:36 +0000 (04:50 +0000)
This fixes two tiny defects in analysis.py that I didn't catch on time in #107564:

- `get_var_names` in `check_macro_consistency` should skip `UNUSED` names.
- Fix an occurrence of `is UNUSED` (should be `==`).

Tools/cases_generator/analysis.py

index bd8918a87ffe08f2c799d639ac984ffeecec8cf2..2db1cd01c19ae5df233899c67a1563f040ef01d1 100644 (file)
@@ -297,6 +297,8 @@ class Analyzer:
         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(
@@ -335,7 +337,7 @@ class Analyzer:
                 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)