From d926d4f7a567bcb7a786429c3a722ae62378295a Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Fri, 8 May 2020 14:58:26 +0300 Subject: [PATCH 1/3] bpo-40334: Improvements to error-handling code in the PEG parser Following improvements are implemented in this PR: - `p->error_indicator` is set, in case malloc or realloc fail - Avoid memory leaks in the case that realloc fails - Call `PyErr_NoMemory()` instead of `PyErr_Format()`, because it requires no memory. --- Parser/pegen/parse.c | 1152 +++++++++++++++------- Tools/peg_generator/pegen/c_generator.py | 34 +- 2 files changed, 807 insertions(+), 379 deletions(-) diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index ae86841e8663b0..34043e159ab7e0 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -10974,7 +10974,8 @@ _loop0_1_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -10988,11 +10989,15 @@ _loop0_1_rule(Parser *p) res = newline_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -11001,8 +11006,9 @@ _loop0_1_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_1"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -11023,7 +11029,8 @@ _loop0_2_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -11037,11 +11044,15 @@ _loop0_2_rule(Parser *p) res = newline_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -11050,8 +11061,9 @@ _loop0_2_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_2"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -11072,7 +11084,8 @@ _loop0_4_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -11094,11 +11107,15 @@ _loop0_4_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -11107,8 +11124,9 @@ _loop0_4_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_4"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -11157,7 +11175,8 @@ _loop0_6_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -11179,11 +11198,15 @@ _loop0_6_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -11192,8 +11215,9 @@ _loop0_6_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_6"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -11242,7 +11266,8 @@ _loop0_8_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -11264,11 +11289,15 @@ _loop0_8_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -11277,8 +11306,9 @@ _loop0_8_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_8"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -11327,7 +11357,8 @@ _loop0_10_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -11349,11 +11380,15 @@ _loop0_10_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -11362,8 +11397,9 @@ _loop0_10_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_10"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -11412,7 +11448,8 @@ _loop1_11_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -11426,11 +11463,15 @@ _loop1_11_rule(Parser *p) res = statement_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -11443,8 +11484,9 @@ _loop1_11_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_11"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -11465,7 +11507,8 @@ _loop0_13_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -11487,11 +11530,15 @@ _loop0_13_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -11500,8 +11547,9 @@ _loop0_13_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_13"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -11851,7 +11899,8 @@ _loop1_22_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -11865,11 +11914,15 @@ _loop1_22_rule(Parser *p) res = _tmp_134_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -11882,8 +11935,9 @@ _loop1_22_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_22"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -11976,7 +12030,8 @@ _loop0_26_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -11998,11 +12053,15 @@ _loop0_26_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -12011,8 +12070,9 @@ _loop0_26_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_26"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -12061,7 +12121,8 @@ _loop0_28_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -12083,11 +12144,15 @@ _loop0_28_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -12096,8 +12161,9 @@ _loop0_28_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_28"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -12178,7 +12244,8 @@ _loop0_30_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -12192,11 +12259,15 @@ _loop0_30_rule(Parser *p) res = _tmp_135_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -12205,8 +12276,9 @@ _loop0_30_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_30"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -12227,7 +12299,8 @@ _loop1_31_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -12241,11 +12314,15 @@ _loop1_31_rule(Parser *p) res = _tmp_136_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -12258,8 +12335,9 @@ _loop1_31_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_31"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -12280,7 +12358,8 @@ _loop0_33_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -12302,11 +12381,15 @@ _loop0_33_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -12315,8 +12398,9 @@ _loop0_33_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_33"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -12397,7 +12481,8 @@ _loop0_36_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -12419,11 +12504,15 @@ _loop0_36_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -12432,8 +12521,9 @@ _loop0_36_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_36"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -12514,7 +12604,8 @@ _loop0_39_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -12536,11 +12627,15 @@ _loop0_39_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -12549,8 +12644,9 @@ _loop0_39_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_39"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -12599,7 +12695,8 @@ _loop0_41_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -12621,11 +12718,15 @@ _loop0_41_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -12634,8 +12735,9 @@ _loop0_41_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_41"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -12684,7 +12786,8 @@ _loop0_43_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -12706,11 +12809,15 @@ _loop0_43_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -12719,8 +12826,9 @@ _loop0_43_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_43"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -12769,7 +12877,8 @@ _loop0_45_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -12791,11 +12900,15 @@ _loop0_45_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -12804,8 +12917,9 @@ _loop0_45_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_45"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -12886,7 +13000,8 @@ _loop1_47_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -12900,11 +13015,15 @@ _loop1_47_rule(Parser *p) res = except_block_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -12917,8 +13036,9 @@ _loop1_47_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_47"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13095,7 +13215,8 @@ _loop0_53_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13109,11 +13230,15 @@ _loop0_53_rule(Parser *p) res = param_no_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13122,8 +13247,9 @@ _loop0_53_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_53"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13144,7 +13270,8 @@ _loop0_54_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13158,11 +13285,15 @@ _loop0_54_rule(Parser *p) res = param_with_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13171,8 +13302,9 @@ _loop0_54_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_54"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13193,7 +13325,8 @@ _loop0_55_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13207,11 +13340,15 @@ _loop0_55_rule(Parser *p) res = param_with_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13220,8 +13357,9 @@ _loop0_55_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_55"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13242,7 +13380,8 @@ _loop1_56_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13256,11 +13395,15 @@ _loop1_56_rule(Parser *p) res = param_no_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13273,8 +13416,9 @@ _loop1_56_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_56"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13295,7 +13439,8 @@ _loop0_57_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13309,11 +13454,15 @@ _loop0_57_rule(Parser *p) res = param_with_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13322,8 +13471,9 @@ _loop0_57_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_57"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13344,7 +13494,8 @@ _loop1_58_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13358,11 +13509,15 @@ _loop1_58_rule(Parser *p) res = param_with_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13375,8 +13530,9 @@ _loop1_58_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_58"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13397,7 +13553,8 @@ _loop1_59_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13411,11 +13568,15 @@ _loop1_59_rule(Parser *p) res = param_no_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13428,8 +13589,9 @@ _loop1_59_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_59"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13450,7 +13612,8 @@ _loop1_60_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13464,11 +13627,15 @@ _loop1_60_rule(Parser *p) res = param_no_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13481,8 +13648,9 @@ _loop1_60_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_60"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13503,7 +13671,8 @@ _loop0_61_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13517,11 +13686,15 @@ _loop0_61_rule(Parser *p) res = param_no_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13530,8 +13703,9 @@ _loop0_61_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_61"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13552,7 +13726,8 @@ _loop1_62_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13566,11 +13741,15 @@ _loop1_62_rule(Parser *p) res = param_with_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13583,8 +13762,9 @@ _loop1_62_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_62"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13605,7 +13785,8 @@ _loop0_63_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13619,11 +13800,15 @@ _loop0_63_rule(Parser *p) res = param_no_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13632,8 +13817,9 @@ _loop0_63_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_63"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13654,7 +13840,8 @@ _loop1_64_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13668,11 +13855,15 @@ _loop1_64_rule(Parser *p) res = param_with_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13685,8 +13876,9 @@ _loop1_64_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_64"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13707,7 +13899,8 @@ _loop0_65_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13721,11 +13914,15 @@ _loop0_65_rule(Parser *p) res = param_maybe_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13734,8 +13931,9 @@ _loop0_65_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_65"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13756,7 +13954,8 @@ _loop1_66_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13770,11 +13969,15 @@ _loop1_66_rule(Parser *p) res = param_maybe_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13787,8 +13990,9 @@ _loop1_66_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_66"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13809,7 +14013,8 @@ _loop1_67_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13823,11 +14028,15 @@ _loop1_67_rule(Parser *p) res = _tmp_137_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13840,8 +14049,9 @@ _loop1_67_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_67"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13897,7 +14107,8 @@ _loop0_70_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13919,11 +14130,15 @@ _loop0_70_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -13932,8 +14147,9 @@ _loop0_70_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_70"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -13982,7 +14198,8 @@ _loop1_71_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -13996,11 +14213,15 @@ _loop1_71_rule(Parser *p) res = _tmp_138_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14013,8 +14234,9 @@ _loop1_71_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_71"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14035,7 +14257,8 @@ _loop0_73_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14057,11 +14280,15 @@ _loop0_73_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14070,8 +14297,9 @@ _loop0_73_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_73"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14120,7 +14348,8 @@ _loop1_74_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14134,11 +14363,15 @@ _loop1_74_rule(Parser *p) res = _tmp_139_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14151,8 +14384,9 @@ _loop1_74_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_74"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14173,7 +14407,8 @@ _loop0_75_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14187,11 +14422,15 @@ _loop0_75_rule(Parser *p) res = lambda_param_no_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14200,8 +14439,9 @@ _loop0_75_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_75"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14222,7 +14462,8 @@ _loop0_76_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14236,11 +14477,15 @@ _loop0_76_rule(Parser *p) res = lambda_param_with_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14249,8 +14494,9 @@ _loop0_76_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_76"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14271,7 +14517,8 @@ _loop0_77_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14285,11 +14532,15 @@ _loop0_77_rule(Parser *p) res = lambda_param_with_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14298,8 +14549,9 @@ _loop0_77_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_77"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14320,7 +14572,8 @@ _loop1_78_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14334,11 +14587,15 @@ _loop1_78_rule(Parser *p) res = lambda_param_no_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14351,8 +14608,9 @@ _loop1_78_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_78"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14373,7 +14631,8 @@ _loop0_79_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14387,11 +14646,15 @@ _loop0_79_rule(Parser *p) res = lambda_param_with_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14400,8 +14663,9 @@ _loop0_79_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_79"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14422,7 +14686,8 @@ _loop1_80_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14436,11 +14701,15 @@ _loop1_80_rule(Parser *p) res = lambda_param_with_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14453,8 +14722,9 @@ _loop1_80_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_80"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14475,7 +14745,8 @@ _loop1_81_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14489,11 +14760,15 @@ _loop1_81_rule(Parser *p) res = lambda_param_no_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14506,8 +14781,9 @@ _loop1_81_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_81"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14528,7 +14804,8 @@ _loop1_82_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14542,11 +14819,15 @@ _loop1_82_rule(Parser *p) res = lambda_param_no_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14559,8 +14840,9 @@ _loop1_82_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_82"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14581,7 +14863,8 @@ _loop0_83_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14595,11 +14878,15 @@ _loop0_83_rule(Parser *p) res = lambda_param_no_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14608,8 +14895,9 @@ _loop0_83_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_83"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14630,7 +14918,8 @@ _loop1_84_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14644,11 +14933,15 @@ _loop1_84_rule(Parser *p) res = lambda_param_with_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14661,8 +14954,9 @@ _loop1_84_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_84"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14683,7 +14977,8 @@ _loop0_85_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14697,11 +14992,15 @@ _loop0_85_rule(Parser *p) res = lambda_param_no_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14710,8 +15009,9 @@ _loop0_85_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_85"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14732,7 +15032,8 @@ _loop1_86_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14746,11 +15047,15 @@ _loop1_86_rule(Parser *p) res = lambda_param_with_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14763,8 +15068,9 @@ _loop1_86_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_86"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14785,7 +15091,8 @@ _loop0_87_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14799,11 +15106,15 @@ _loop0_87_rule(Parser *p) res = lambda_param_maybe_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14812,8 +15123,9 @@ _loop0_87_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_87"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14834,7 +15146,8 @@ _loop1_88_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14848,11 +15161,15 @@ _loop1_88_rule(Parser *p) res = lambda_param_maybe_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14865,8 +15182,9 @@ _loop1_88_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_88"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14887,7 +15205,8 @@ _loop1_89_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14901,11 +15220,15 @@ _loop1_89_rule(Parser *p) res = _tmp_140_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14918,8 +15241,9 @@ _loop1_89_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_89"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14940,7 +15264,8 @@ _loop1_90_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -14954,11 +15279,15 @@ _loop1_90_rule(Parser *p) res = _tmp_141_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -14971,8 +15300,9 @@ _loop1_90_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_90"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -14993,7 +15323,8 @@ _loop1_91_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -15007,11 +15338,15 @@ _loop1_91_rule(Parser *p) res = compare_op_bitwise_or_pair_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -15024,8 +15359,9 @@ _loop1_91_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_91"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -15075,7 +15411,8 @@ _loop0_94_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -15097,11 +15434,15 @@ _loop0_94_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -15110,8 +15451,9 @@ _loop0_94_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_94"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -15333,7 +15675,8 @@ _loop1_99_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -15347,11 +15690,15 @@ _loop1_99_rule(Parser *p) res = string_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -15364,8 +15711,9 @@ _loop1_99_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_99"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -15457,7 +15805,8 @@ _loop0_103_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -15479,11 +15828,15 @@ _loop0_103_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -15492,8 +15845,9 @@ _loop0_103_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_103"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -15542,7 +15896,8 @@ _loop1_104_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -15556,11 +15911,15 @@ _loop1_104_rule(Parser *p) res = for_if_clause_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -15573,8 +15932,9 @@ _loop1_104_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_104"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -15595,7 +15955,8 @@ _loop0_105_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -15609,11 +15970,15 @@ _loop0_105_rule(Parser *p) res = _tmp_142_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -15622,8 +15987,9 @@ _loop0_105_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_105"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -15644,7 +16010,8 @@ _loop0_106_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -15658,11 +16025,15 @@ _loop0_106_rule(Parser *p) res = _tmp_143_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -15671,8 +16042,9 @@ _loop0_106_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_106"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -15757,7 +16129,8 @@ _loop0_110_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -15779,11 +16152,15 @@ _loop0_110_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -15792,8 +16169,9 @@ _loop0_110_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_110"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -15842,7 +16220,8 @@ _loop0_112_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -15864,11 +16243,15 @@ _loop0_112_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -15877,8 +16260,9 @@ _loop0_112_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_112"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -15927,7 +16311,8 @@ _loop0_114_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -15949,11 +16334,15 @@ _loop0_114_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -15962,8 +16351,9 @@ _loop0_114_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_114"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -16012,7 +16402,8 @@ _loop0_116_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -16034,11 +16425,15 @@ _loop0_116_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -16047,8 +16442,9 @@ _loop0_116_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_116"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -16097,7 +16493,8 @@ _loop0_117_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -16111,11 +16508,15 @@ _loop0_117_rule(Parser *p) res = _tmp_144_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -16124,8 +16525,9 @@ _loop0_117_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_117"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -16146,7 +16548,8 @@ _loop0_119_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -16168,11 +16571,15 @@ _loop0_119_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -16181,8 +16588,9 @@ _loop0_119_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_119"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -16258,7 +16666,8 @@ _loop0_122_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -16280,11 +16689,15 @@ _loop0_122_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -16293,8 +16706,9 @@ _loop0_122_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_122"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -16343,7 +16757,8 @@ _loop0_124_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -16365,11 +16780,15 @@ _loop0_124_rule(Parser *p) } if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -16378,8 +16797,9 @@ _loop0_124_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_124"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -16614,7 +17034,8 @@ _loop0_130_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -16628,11 +17049,15 @@ _loop0_130_rule(Parser *p) res = param_no_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -16641,8 +17066,9 @@ _loop0_130_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_130"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); @@ -17140,7 +17566,8 @@ _loop1_145_rule(Parser *p) int start_mark = p->mark; void **children = PyMem_Malloc(sizeof(void *)); if (!children) { - PyErr_Format(PyExc_MemoryError, "Parser out of memory"); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } ssize_t children_capacity = 1; @@ -17154,11 +17581,15 @@ _loop1_145_rule(Parser *p) res = param_with_default_var; if (n == children_capacity) { children_capacity *= 2; - children = PyMem_Realloc(children, children_capacity*sizeof(void *)); - if (!children) { - PyErr_Format(PyExc_MemoryError, "realloc None"); + void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *)); + if (!new_children) { + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } + else { + children = new_children; + } } children[n++] = res; mark = p->mark; @@ -17171,8 +17602,9 @@ _loop1_145_rule(Parser *p) } asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); if (!seq) { - PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_145"); PyMem_Free(children); + p->error_indicator = 1; + PyErr_NoMemory(); return NULL; } for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); diff --git a/Tools/peg_generator/pegen/c_generator.py b/Tools/peg_generator/pegen/c_generator.py index b7a9942c2fdd27..642358b01da5c6 100644 --- a/Tools/peg_generator/pegen/c_generator.py +++ b/Tools/peg_generator/pegen/c_generator.py @@ -318,24 +318,21 @@ def call_with_errorcheck_goto(self, call_text: str, goto_target: str) -> None: def out_of_memory_return( self, expr: str, - returnval: str, - message: str = "Parser out of memory", cleanup_code: Optional[str] = None, ) -> None: self.print(f"if ({expr}) {{") with self.indent(): - self.print(f'PyErr_Format(PyExc_MemoryError, "{message}");') if cleanup_code is not None: self.print(cleanup_code) - self.print(f"return {returnval};") + self.print("p->error_indicator = 1;") + self.print("PyErr_NoMemory();"); + self.print("return NULL;") self.print(f"}}") - def out_of_memory_goto( - self, expr: str, goto_target: str, message: str = "Parser out of memory" - ) -> None: + def out_of_memory_goto(self, expr: str, goto_target: str) -> None: self.print(f"if ({expr}) {{") with self.indent(): - self.print(f'PyErr_Format(PyExc_MemoryError, "{message}");') + self.print("PyErr_NoMemory();") self.print(f"goto {goto_target};") self.print(f"}}") @@ -485,7 +482,7 @@ def _handle_default_rule_body(self, node: Rule, rhs: Rhs, result_type: str) -> N rhs, is_loop=False, is_gather=node.is_gather(), - rulename=node.name if memoize else None, + rulename=node.name, ) if self.debug: self.print(f'fprintf(stderr, "Fail at %d: {node.name}\\n", p->mark);') @@ -513,7 +510,7 @@ def _handle_loop_rule_body(self, node: Rule, rhs: Rhs) -> None: self.print("int mark = p->mark;") self.print("int start_mark = p->mark;") self.print("void **children = PyMem_Malloc(sizeof(void *));") - self.out_of_memory_return(f"!children", "NULL") + self.out_of_memory_return(f"!children") self.print("ssize_t children_capacity = 1;") self.print("ssize_t n = 0;") if any(alt.action and "EXTRA" in alt.action for alt in rhs.alts): @@ -522,7 +519,7 @@ def _handle_loop_rule_body(self, node: Rule, rhs: Rhs) -> None: rhs, is_loop=True, is_gather=node.is_gather(), - rulename=node.name if memoize else None, + rulename=node.name, ) if is_repeat1: self.print("if (n == 0 || p->error_indicator) {") @@ -531,12 +528,7 @@ def _handle_loop_rule_body(self, node: Rule, rhs: Rhs) -> None: self.print("return NULL;") self.print("}") self.print("asdl_seq *seq = _Py_asdl_seq_new(n, p->arena);") - self.out_of_memory_return( - f"!seq", - "NULL", - message=f"asdl_seq_new {node.name}", - cleanup_code="PyMem_Free(children);", - ) + self.out_of_memory_return(f"!seq", cleanup_code="PyMem_Free(children);") self.print("for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]);") self.print("PyMem_Free(children);") if node.name: @@ -680,8 +672,12 @@ def handle_alt_loop(self, node: Alt, is_gather: bool, rulename: Optional[str]) - self.print("if (n == children_capacity) {") with self.indent(): self.print("children_capacity *= 2;") - self.print("children = PyMem_Realloc(children, children_capacity*sizeof(void *));") - self.out_of_memory_return(f"!children", "NULL", message=f"realloc {rulename}") + self.print("void **new_children = PyMem_Realloc(children, children_capacity*sizeof(void *));") + self.out_of_memory_return(f"!new_children") + self.print("else {") # out_of_memory_return generates an if + with self.indent(): + self.print("children = new_children;") + self.print("}") self.print("}") self.print(f"children[n++] = res;") self.print("mark = p->mark;") From c90c702e1f9b32c9a6612fb25da41c3bba5d863f Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Sun, 17 May 2020 05:25:24 +0300 Subject: [PATCH 2/3] Remove unnecessary else clause in generated code Co-authored-by: Pablo Galindo --- Tools/peg_generator/pegen/c_generator.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Tools/peg_generator/pegen/c_generator.py b/Tools/peg_generator/pegen/c_generator.py index b15f1920dc087f..8f9972bb41a522 100644 --- a/Tools/peg_generator/pegen/c_generator.py +++ b/Tools/peg_generator/pegen/c_generator.py @@ -676,10 +676,7 @@ def handle_alt_loop(self, node: Alt, is_gather: bool, rulename: Optional[str]) - self.print("_children_capacity *= 2;") self.print("void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));") self.out_of_memory_return(f"!_new_children") - self.print("else {") # out_of_memory_return generates an if - with self.indent(): - self.print("_children = _new_children;") - self.print("}") + self.print("_children = _new_children;") self.print("}") self.print("_children[_n++] = _res;") self.print("_mark = p->mark;") From 75335ff77c537ef68bf9da7be5aa82d386c2c0c7 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Sun, 17 May 2020 05:33:26 +0300 Subject: [PATCH 3/3] Regenerate parse.c --- Parser/pegen/parse.c | 292 +++++++++++-------------------------------- 1 file changed, 73 insertions(+), 219 deletions(-) diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c index 1970406518acd0..2a9dad7d1d7ef5 100644 --- a/Parser/pegen/parse.c +++ b/Parser/pegen/parse.c @@ -11160,9 +11160,7 @@ _loop0_1_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -11215,9 +11213,7 @@ _loop0_2_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -11278,9 +11274,7 @@ _loop0_4_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -11369,9 +11363,7 @@ _loop0_6_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -11460,9 +11452,7 @@ _loop0_8_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -11551,9 +11541,7 @@ _loop0_10_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -11634,9 +11622,7 @@ _loop1_11_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -11701,9 +11687,7 @@ _loop0_13_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -12085,9 +12069,7 @@ _loop1_22_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -12224,9 +12206,7 @@ _loop0_26_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -12315,9 +12295,7 @@ _loop0_28_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -12430,9 +12408,7 @@ _loop0_30_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -12485,9 +12461,7 @@ _loop1_31_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -12552,9 +12526,7 @@ _loop0_33_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -12675,9 +12647,7 @@ _loop0_36_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -12798,9 +12768,7 @@ _loop0_39_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -12889,9 +12857,7 @@ _loop0_41_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -12980,9 +12946,7 @@ _loop0_43_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -13071,9 +13035,7 @@ _loop0_45_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -13186,9 +13148,7 @@ _loop1_47_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -13401,9 +13361,7 @@ _loop0_53_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -13456,9 +13414,7 @@ _loop0_54_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -13511,9 +13467,7 @@ _loop0_55_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -13566,9 +13520,7 @@ _loop1_56_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -13625,9 +13577,7 @@ _loop0_57_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -13680,9 +13630,7 @@ _loop1_58_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -13739,9 +13687,7 @@ _loop1_59_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -13798,9 +13744,7 @@ _loop1_60_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -13857,9 +13801,7 @@ _loop0_61_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -13912,9 +13854,7 @@ _loop1_62_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -13971,9 +13911,7 @@ _loop0_63_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14026,9 +13964,7 @@ _loop1_64_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14085,9 +14021,7 @@ _loop0_65_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14140,9 +14074,7 @@ _loop1_66_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14199,9 +14131,7 @@ _loop1_67_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14301,9 +14231,7 @@ _loop0_70_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14384,9 +14312,7 @@ _loop1_71_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14451,9 +14377,7 @@ _loop0_73_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14534,9 +14458,7 @@ _loop1_74_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14593,9 +14515,7 @@ _loop0_75_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14648,9 +14568,7 @@ _loop0_76_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14703,9 +14621,7 @@ _loop0_77_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14758,9 +14674,7 @@ _loop1_78_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14817,9 +14731,7 @@ _loop0_79_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14872,9 +14784,7 @@ _loop1_80_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14931,9 +14841,7 @@ _loop1_81_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -14990,9 +14898,7 @@ _loop1_82_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -15049,9 +14955,7 @@ _loop0_83_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -15104,9 +15008,7 @@ _loop1_84_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -15163,9 +15065,7 @@ _loop0_85_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -15218,9 +15118,7 @@ _loop1_86_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -15277,9 +15175,7 @@ _loop0_87_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -15332,9 +15228,7 @@ _loop1_88_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -15391,9 +15285,7 @@ _loop1_89_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -15450,9 +15342,7 @@ _loop1_90_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -15509,9 +15399,7 @@ _loop1_91_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -15605,9 +15493,7 @@ _loop0_94_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -15861,9 +15747,7 @@ _loop1_99_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -15999,9 +15883,7 @@ _loop0_103_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -16082,9 +15964,7 @@ _loop1_104_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -16141,9 +16021,7 @@ _loop0_105_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -16196,9 +16074,7 @@ _loop0_106_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -16323,9 +16199,7 @@ _loop0_110_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -16414,9 +16288,7 @@ _loop0_112_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -16505,9 +16377,7 @@ _loop0_114_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -16596,9 +16466,7 @@ _loop0_116_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -16679,9 +16547,7 @@ _loop0_117_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -16742,9 +16608,7 @@ _loop0_119_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -16860,9 +16724,7 @@ _loop0_122_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -16951,9 +16813,7 @@ _loop0_124_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -17073,9 +16933,7 @@ _loop0_126_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -17275,9 +17133,7 @@ _loop0_131_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark; @@ -17807,9 +17663,7 @@ _loop1_146_rule(Parser *p) PyErr_NoMemory(); return NULL; } - else { - _children = _new_children; - } + _children = _new_children; } _children[_n++] = _res; _mark = p->mark;