diff options
| author | Pablo Galindo <Pablogsal@gmail.com> | 2019-10-30 11:53:26 +0000 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-30 11:53:26 +0000 | 
| commit | 6c3e66a34b95fff07df0ad5086104dd637a091ce (patch) | |
| tree | 3717be95d4016c94d16cce66aa4581a7cfb14a4e /Python/compile.c | |
| parent | 24c6258269acd842914450f55491690ba87dded9 (diff) | |
| download | cpython-git-6c3e66a34b95fff07df0ad5086104dd637a091ce.tar.gz | |
bpo-38640: Allow break and continue in always false while loops (GH-16992)
Diffstat (limited to 'Python/compile.c')
| -rw-r--r-- | Python/compile.c | 8 | 
1 files changed, 8 insertions, 0 deletions
| diff --git a/Python/compile.c b/Python/compile.c index 3b2188e6e7..f26ad3c775 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -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); | 
