bpo-38640: Allow break and continue in always false while loops (GH-16992)

This commit is contained in:
Pablo Galindo 2019-10-30 11:53:26 +00:00 committed by GitHub
parent 24c6258269
commit 6c3e66a34b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 0 deletions

View file

@ -2738,7 +2738,15 @@ compiler_while(struct compiler *c, stmt_ty s)
if (constant == 0) {
BEGIN_DO_NOT_EMIT_BYTECODE
// Push a dummy block so the VISIT_SEQ knows that we are
// inside a while loop so it can correctly evaluate syntax
// errors.
if (!compiler_push_fblock(c, WHILE_LOOP, NULL, NULL)) {
return 0;
}
VISIT_SEQ(c, stmt, s->v.While.body);
// Remove the dummy block now that is not needed.
compiler_pop_fblock(c, WHILE_LOOP, NULL);
END_DO_NOT_EMIT_BYTECODE
if (s->v.While.orelse) {
VISIT_SEQ(c, stmt, s->v.While.orelse);