Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 384639f

Browse files
committed
When running python -O, do not include blocks defined in asserts in
the symbol table pass. These blocks were already ignored by the code gen pass. Both passes must visit the same set of blocks in the same order. Fixes SF buf 132820
1 parent 4779399 commit 384639f

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

Python/compile.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4496,6 +4496,17 @@ symtable_node(struct symtable *st, node *n)
44964496
break;
44974497

44984498
}
4499+
case assert_stmt:
4500+
if (Py_OptimizeFlag)
4501+
return;
4502+
if (NCH(n) == 2) {
4503+
n = CHILD(n, 1);
4504+
goto loop;
4505+
} else {
4506+
symtable_node(st, CHILD(n, 1));
4507+
n = CHILD(n, 3);
4508+
goto loop;
4509+
}
44994510
case except_clause:
45004511
if (NCH(n) == 4)
45014512
symtable_assign(st, CHILD(n, 3), 0);

0 commit comments

Comments
 (0)