You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Merge pull request #379 from rocky/elif-transformation-with-continue
Elif transformation with continue
This commit is contained in:
BIN
test/bytecode_2.4_run/02_loop_continue_dead_code.pyc
Normal file
BIN
test/bytecode_2.4_run/02_loop_continue_dead_code.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_2.6_run/02_loop_continue_dead_code.pyc
Normal file
BIN
test/bytecode_2.6_run/02_loop_continue_dead_code.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_2.7_run/02_loop_continue_dead_code.pyc
Normal file
BIN
test/bytecode_2.7_run/02_loop_continue_dead_code.pyc
Normal file
Binary file not shown.
18
test/simple_source/bug24/02_loop_continue_dead_code.py
Normal file
18
test/simple_source/bug24/02_loop_continue_dead_code.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
"""This program is self-checking!"""
|
||||||
|
# Python 2.4 - 2.7 bug in transforming "else if" to "elif" in Python 2.4 .. 2.7
|
||||||
|
# From Issue #377
|
||||||
|
|
||||||
|
# RUNNABLE!
|
||||||
|
def loop_continue_dead_code(slots):
|
||||||
|
for name in slots:
|
||||||
|
if name:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
# The below is dead code
|
||||||
|
if x:
|
||||||
|
y()
|
||||||
|
else:
|
||||||
|
z()
|
||||||
|
|
||||||
|
loop_continue_dead_code([None, 1])
|
@@ -293,7 +293,8 @@ class TreeTransform(GenericASTTraversal, object):
|
|||||||
else_suite_index = 1
|
else_suite_index = 1
|
||||||
|
|
||||||
len_n = len(n)
|
len_n = len(n)
|
||||||
if len_n == 1 == len(n[0]) and n[0] == "stmt":
|
# Sometimes stmt is reduced away and n[0] can be a single reduction like continue -> CONTINUE.
|
||||||
|
if len_n == 1 and isinstance(n[0], SyntaxTree) and len(n[0]) == 1 and n[0] == "stmt":
|
||||||
n = n[0][0]
|
n = n[0][0]
|
||||||
elif len_n == 0:
|
elif len_n == 0:
|
||||||
return node
|
return node
|
||||||
|
Reference in New Issue
Block a user