gh-113602: Bail out when the parser tries to override existing errors (GH-113607)
(cherry picked from commit
9ed36d533ab8b256f0a589b5be6d7a2fdcf4aff2)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
"""
self._check_error(code, "parenthesis '\\)' does not match opening parenthesis '\\['")
+ self._check_error("match y:\n case e(e=v,v,", " was never closed")
+
# Examples with dencodings
s = b'# coding=latin\n(aaaaaaaaaaaaaaaaa\naaaaaaaaaaa\xb5'
self._check_error(s, r"'\(' was never closed")
--- /dev/null
+Fix an error that was causing the parser to try to overwrite existing errors
+and crashing in the process. Patch by Pablo Galindo
Py_ssize_t end_lineno, Py_ssize_t end_col_offset,
const char *errmsg, va_list va)
{
+ // Bail out if we already have an error set.
+ if (p->error_indicator && PyErr_Occurred()) {
+ return NULL;
+ }
PyObject *value = NULL;
PyObject *errstr = NULL;
PyObject *error_line = NULL;