Skip to content
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