[Python-checkins] gh-106812: Fix two tiny bugs in analysis.py (#107649)

gvanrossum webhook-mailer at python.org
Sat Aug 5 00:50:40 EDT 2023


https://github.com/python/cpython/commit/85e5b1f5b806289744ef9a5a13dabfb23044f713
commit: 85e5b1f5b806289744ef9a5a13dabfb23044f713
branch: main
author: Guido van Rossum <guido at python.org>
committer: gvanrossum <gvanrossum at gmail.com>
date: 2023-08-05T04:50:36Z
summary:

gh-106812: Fix two tiny bugs in analysis.py (#107649)

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 `==`).

files:
M Tools/cases_generator/analysis.py

diff --git a/Tools/cases_generator/analysis.py b/Tools/cases_generator/analysis.py
index bd8918a87ffe0..2db1cd01c19ae 100644
--- a/Tools/cases_generator/analysis.py
+++ b/Tools/cases_generator/analysis.py
@@ -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(
@@ -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)



More information about the Python-checkins mailing list