diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-01-24 22:51:18 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-01-24 22:51:18 (GMT) |
commit | 16570f59caecde43b13b0e5f4c9328e4ceded544 (patch) | |
tree | 4e85aacb3816816b40bc6e099313b234734781b0 /Python | |
parent | 5310b6941965afa3a40e61e8315590c931dc47e6 (diff) | |
download | cpython-16570f59caecde43b13b0e5f4c9328e4ceded544.zip cpython-16570f59caecde43b13b0e5f4c9328e4ceded544.tar.gz cpython-16570f59caecde43b13b0e5f4c9328e4ceded544.tar.bz2 |
#1920: when considering a block starting by "while 0", the compiler optimized the
whole construct away, even when an 'else' clause is present::
while 0:
print("no")
else:
print("yes")
did not generate any code at all.
Now the compiler emits the 'else' block, like it already does for 'if' statements.
Will backport.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/compile.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Python/compile.c b/Python/compile.c index c77091e..aee7bda 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1598,8 +1598,11 @@ compiler_while(struct compiler *c, stmt_ty s) basicblock *loop, *orelse, *end, *anchor = NULL; int constant = expr_constant(s->v.While.test); - if (constant == 0) + if (constant == 0) { + if (s->v.While.orelse) + VISIT_SEQ(c, stmt, s->v.While.orelse); return 1; + } loop = compiler_new_block(c); end = compiler_new_block(c); if (constant == -1) { |