[Python-checkins] bpo-40334: Support suppressing of multiple optional variables in Pegen (GH-20367)

Batuhan Taskaya webhook-mailer at python.org
Sun May 24 18:20:23 EDT 2020


https://github.com/python/cpython/commit/cba503151056b448b7a3730dc36ef6655550ade5
commit: cba503151056b448b7a3730dc36ef6655550ade5
branch: master
author: Batuhan Taskaya <batuhanosmantaskaya at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-05-24T23:20:18+01:00
summary:

bpo-40334: Support suppressing of multiple optional variables in Pegen (GH-20367)

files:
M Tools/peg_generator/pegen/c_generator.py

diff --git a/Tools/peg_generator/pegen/c_generator.py b/Tools/peg_generator/pegen/c_generator.py
index 362698b0df62e..1249d4f683e26 100644
--- a/Tools/peg_generator/pegen/c_generator.py
+++ b/Tools/peg_generator/pegen/c_generator.py
@@ -694,8 +694,8 @@ def visit_Alt(
                 if v == "_cut_var":
                     v += " = 0"  # cut_var must be initialized
                 self.print(f"{var_type}{v};")
-                if v == "_opt_var":
-                    self.print("UNUSED(_opt_var); // Silence compiler warnings")
+                if v.startswith("_opt_var"):
+                    self.print(f"UNUSED({v}); // Silence compiler warnings")
 
             with self.local_variable_context():
                 if is_loop:



More information about the Python-checkins mailing list