diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2022-01-03 18:29:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-03 18:29:18 (GMT) |
commit | 9d35dedc5e7e940b639230fba93c763bd9f19c09 (patch) | |
tree | ef78245f7f08d1012db04413feb61ba36c7c92b5 /Tools | |
parent | c960b191b8999a9455bb4b2c50dc224d06fee80c (diff) | |
download | cpython-9d35dedc5e7e940b639230fba93c763bd9f19c09.zip cpython-9d35dedc5e7e940b639230fba93c763bd9f19c09.tar.gz cpython-9d35dedc5e7e940b639230fba93c763bd9f19c09.tar.bz2 |
Revert "bpo-46110: Add a recursion check to avoid stack overflow in the PEG parser (GH-30177)" (GH-30363)
This reverts commit e9898bf153d26059261ffef11f7643ae991e2a4c temporarily as we want to confirm if this commit is the cause of a slowdown at startup time.
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/peg_generator/pegen/c_generator.py | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/Tools/peg_generator/pegen/c_generator.py b/Tools/peg_generator/pegen/c_generator.py index ee255c8..9cfbf38 100644 --- a/Tools/peg_generator/pegen/c_generator.py +++ b/Tools/peg_generator/pegen/c_generator.py @@ -37,8 +37,6 @@ EXTENSION_PREFIX = """\ # define D(x) #endif -# define MAXSTACK 6000 - """ @@ -366,14 +364,10 @@ class CParserGenerator(ParserGenerator, GrammarVisitor): self.skip_actions = skip_actions def add_level(self) -> None: - self.print("if (p->level++ == MAXSTACK) {") - with self.indent(): - self.print("p->error_indicator = 1;") - self.print("PyErr_NoMemory();") - self.print("}") + self.print("D(p->level++);") def remove_level(self) -> None: - self.print("p->level--;") + self.print("D(p->level--);") def add_return(self, ret_val: str) -> None: self.remove_level() @@ -550,10 +544,9 @@ class CParserGenerator(ParserGenerator, GrammarVisitor): self.print("p->in_raw_rule++;") self.print(f"void *_raw = {node.name}_raw(p);") self.print("p->in_raw_rule--;") - self.print("if (p->error_indicator) {") + self.print("if (p->error_indicator)") with self.indent(): - self.add_return("NULL") - self.print("}") + self.print("return NULL;") self.print("if (_raw == NULL || p->mark <= _resmark)") with self.indent(): self.print("break;") |