-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
in validate_pattern, there are two places where in case of error we break out of a loop, but we also need to break out of the switch.
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -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:
@@ -620,6 +622,9 @@ validate_pattern(struct validator *state, pattern_ty p, int star_ok)
}
}
+ if (ret == 0) {
+ break;
+ }
if (!validate_patterns(state, p->v.MatchClass.patterns, /*star_ok=*/0)) {
ret = 0;
break;
If we don't do this we can end up calling _PyAST_Compile with an error set.
Linked PRs
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error