diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2023-09-22 18:03:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-22 18:03:23 (GMT) |
commit | b28ffaa193efc66f46ab90d383279174a11a11d7 (patch) | |
tree | acea940a825714a0c55c4669d31e23fa08ed8bf0 /Parser/pegen_errors.c | |
parent | 7c553991724d8d537f8444db73f016008753d77a (diff) | |
download | cpython-b28ffaa193efc66f46ab90d383279174a11a11d7.zip cpython-b28ffaa193efc66f46ab90d383279174a11a11d7.tar.gz cpython-b28ffaa193efc66f46ab90d383279174a11a11d7.tar.bz2 |
gh-109596: Ensure repeated rules in the grammar are not allowed and fix incorrect soft keywords (#109606)
Diffstat (limited to 'Parser/pegen_errors.c')
-rw-r--r-- | Parser/pegen_errors.c | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/Parser/pegen_errors.c b/Parser/pegen_errors.c index f400936..b11b044 100644 --- a/Parser/pegen_errors.c +++ b/Parser/pegen_errors.c @@ -310,21 +310,6 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype, end_col_offset = p->tok->cur - p->tok->line_start; } - if (p->start_rule == Py_fstring_input) { - const char *fstring_msg = "f-string: "; - Py_ssize_t len = strlen(fstring_msg) + strlen(errmsg); - - char *new_errmsg = PyMem_Malloc(len + 1); // Lengths of both strings plus NULL character - if (!new_errmsg) { - return (void *) PyErr_NoMemory(); - } - - // Copy both strings into new buffer - memcpy(new_errmsg, fstring_msg, strlen(fstring_msg)); - memcpy(new_errmsg + strlen(fstring_msg), errmsg, strlen(errmsg)); - new_errmsg[len] = 0; - errmsg = new_errmsg; - } errstr = PyUnicode_FromFormatV(errmsg, va); if (!errstr) { goto error; @@ -363,11 +348,6 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype, } } - if (p->start_rule == Py_fstring_input) { - col_offset -= p->starting_col_offset; - end_col_offset -= p->starting_col_offset; - } - Py_ssize_t col_number = col_offset; Py_ssize_t end_col_number = end_col_offset; @@ -398,17 +378,11 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype, Py_DECREF(errstr); Py_DECREF(value); - if (p->start_rule == Py_fstring_input) { - PyMem_Free((void *)errmsg); - } return NULL; error: Py_XDECREF(errstr); Py_XDECREF(error_line); - if (p->start_rule == Py_fstring_input) { - PyMem_Free((void *)errmsg); - } return NULL; } |