Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.12] gh-113602: Bail out when the parser tries to override existing errors (GH-113607) #113652

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/test/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -2322,6 +2322,8 @@ def test_error_parenthesis(self):
"""
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")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix an error that was causing the parser to try to overwrite existing errors
and crashing in the process. Patch by Pablo Galindo
4 changes: 4 additions & 0 deletions Parser/pegen_errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype,
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;
Expand Down