summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-09-18 01:06:50 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-09-18 01:06:50 (GMT)
commite7811fca5ed60ce84ee78327ed485f76a0a09814 (patch)
tree2202d8f6218777b9468a7d289d677b346b281dff /Python/compile.c
parent87538e7bc46885d2ad2cce423603b45d182d6d40 (diff)
downloadcpython-e7811fca5ed60ce84ee78327ed485f76a0a09814.zip
cpython-e7811fca5ed60ce84ee78327ed485f76a0a09814.tar.gz
cpython-e7811fca5ed60ce84ee78327ed485f76a0a09814.tar.bz2
Closes #11471: avoid generating a JUMP_FORWARD instruction at the end of an if-block if there is no else-clause.
Original patch by Eugene Toder.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 9cc1399..e46ec6c 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1940,7 +1940,7 @@ compiler_if(struct compiler *c, stmt_ty s)
} else if (constant == 1) {
VISIT_SEQ(c, stmt, s->v.If.body);
} else {
- if (s->v.If.orelse) {
+ if (asdl_seq_LEN(s->v.If.orelse)) {
next = compiler_new_block(c);
if (next == NULL)
return 0;
@@ -1950,8 +1950,8 @@ compiler_if(struct compiler *c, stmt_ty s)
VISIT(c, expr, s->v.If.test);
ADDOP_JABS(c, POP_JUMP_IF_FALSE, next);
VISIT_SEQ(c, stmt, s->v.If.body);
- ADDOP_JREL(c, JUMP_FORWARD, end);
- if (s->v.If.orelse) {
+ if (asdl_seq_LEN(s->v.If.orelse)) {
+ ADDOP_JREL(c, JUMP_FORWARD, end);
compiler_use_next_block(c, next);
VISIT_SEQ(c, stmt, s->v.If.orelse);
}