Skip to content

gh-104482: Fix error handling bugs in ast.c #104483

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

Merged
merged 11 commits into from
May 15, 2023
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix two error handling bugs in ast.c's parsing of pattern matching statements.
8 changes: 6 additions & 2 deletions Python/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,9 @@ validate_pattern(struct validator *state, pattern_ty p, int star_ok)
break;
}
}

if (ret == 0) {
break;
}
ret = validate_patterns(state, p->v.MatchMapping.patterns, /*star_ok=*/0);
break;
case MatchClass_kind:
Expand Down Expand Up @@ -619,7 +621,9 @@ validate_pattern(struct validator *state, pattern_ty p, int star_ok)
break;
}
}

if (ret == 0) {
break;
}
if (!validate_patterns(state, p->v.MatchClass.patterns, /*star_ok=*/0)) {
ret = 0;
break;
Expand Down
1 change: 1 addition & 0 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ PyCodeObject *
_PyAST_Compile(mod_ty mod, PyObject *filename, PyCompilerFlags *pflags,
int optimize, PyArena *arena)
{
assert(!PyErr_Occurred());
struct compiler *c = new_compiler(mod, filename, pflags, optimize, arena);
if (c == NULL) {
return NULL;
Expand Down