diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2020-09-03 15:29:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-03 15:29:55 +0100 |
commit | e55a0e971b4bf9e6473bf0ca6bebdff76c075ef6 (patch) | |
tree | 5dca77a9c05b0075139bdbd4762a643f782e114e /Tools/peg_generator | |
parent | bpo-41697: Correctly handle KeywordOrStarred when parsing arguments in the pa... (diff) | |
download | cpython-e55a0e971b4bf9e6473bf0ca6bebdff76c075ef6.tar.gz cpython-e55a0e971b4bf9e6473bf0ca6bebdff76c075ef6.tar.bz2 cpython-e55a0e971b4bf9e6473bf0ca6bebdff76c075ef6.zip |
Fix 'gather' rules in the python parser generator (GH-22021)
Currently, empty sequences in gather rules make the conditional for
gather rules fail as empty sequences evaluate as "False". We need to
explicitly check for "None" (the failure condition) to avoid false
negatives.
Diffstat (limited to 'Tools/peg_generator')
-rw-r--r-- | Tools/peg_generator/pegen/python_generator.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Tools/peg_generator/pegen/python_generator.py b/Tools/peg_generator/pegen/python_generator.py index 45a75975dbf..b786de7fee5 100644 --- a/Tools/peg_generator/pegen/python_generator.py +++ b/Tools/peg_generator/pegen/python_generator.py @@ -217,6 +217,9 @@ class PythonParserGenerator(ParserGenerator, GrammarVisitor): else: self.print("and") self.visit(item) + if is_gather: + self.print("is not None") + self.print("):") with self.indent(): action = node.action |