summaryrefslogtreecommitdiffstats
path: root/Tools/peg_generator
diff options
context:
space:
mode:
authorƁukasz Langa <lukasz@langa.pl>2021-10-20 16:51:13 (GMT)
committerGitHub <noreply@github.com>2021-10-20 16:51:13 (GMT)
commit88f4ec88e282bf861f0af2d237e9fe28fbc8deac (patch)
tree289d8b70bca2eee134958dfe5b6311c9f3ccf474 /Tools/peg_generator
parent50e8b2ff0273e81829ed3fa4ab9ef9898fd2b891 (diff)
downloadcpython-88f4ec88e282bf861f0af2d237e9fe28fbc8deac.zip
cpython-88f4ec88e282bf861f0af2d237e9fe28fbc8deac.tar.gz
cpython-88f4ec88e282bf861f0af2d237e9fe28fbc8deac.tar.bz2
[3.9] bpo-45494: Fix parser crash when reporting errors involving invalid continuation characters (GH-28993) (#29071)
There are two errors that this commit fixes: * The parser was not correctly computing the offset and the string source for E_LINECONT errors due to the incorrect usage of strtok(). * The parser was not correctly unwinding the call stack when a tokenizer exception happened in rules involving optionals ('?', [...]) as we always make them return valid results by using the comma operator. We need to check first if we don't have an error before continuing.. (cherry picked from commit a106343f632a99c8ebb0136fa140cf189b4a6a57) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> NOTE: unlike the cherry-picked original, this commit points at a crazy location due to a bug in the tokenizer that required a big refactor in 3.10 to fix. We are leaving as-is for 3.9.
Diffstat (limited to 'Tools/peg_generator')
-rw-r--r--Tools/peg_generator/pegen/c_generator.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Tools/peg_generator/pegen/c_generator.py b/Tools/peg_generator/pegen/c_generator.py
index 692ee69..b5836f6 100644
--- a/Tools/peg_generator/pegen/c_generator.py
+++ b/Tools/peg_generator/pegen/c_generator.py
@@ -85,7 +85,7 @@ class FunctionCall:
if self.arguments:
parts.append(f"({', '.join(map(str, self.arguments))})")
if self.force_true:
- parts.append(", 1")
+ parts.append(", !p->error_indicator")
if self.assigned_variable:
parts = ["(", self.assigned_variable, " = ", *parts, ")"]
if self.comment: