You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Remove restriction that there are no more statements after a "return" statement
This commit is contained in:
BIN
test/bytecode_2.7/05_deadcode.pyc
Normal file
BIN
test/bytecode_2.7/05_deadcode.pyc
Normal file
Binary file not shown.
6
test/simple_source/bug27+/05_deadcode.py
Normal file
6
test/simple_source/bug27+/05_deadcode.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# Test to see we can a program that has dead code in it.
|
||||
# This was issue #150
|
||||
def func(a):
|
||||
if a:
|
||||
return True
|
||||
something_never_run()
|
@@ -505,7 +505,7 @@ class Python2Parser(PythonParser):
|
||||
|
||||
self.check_reduce['aug_assign1'] = 'AST'
|
||||
self.check_reduce['aug_assign2'] = 'AST'
|
||||
self.check_reduce['_stmts'] = 'AST'
|
||||
# self.check_reduce['_stmts'] = 'AST'
|
||||
|
||||
# Dead code testing...
|
||||
# self.check_reduce['while1elsestmt'] = 'tokens'
|
||||
@@ -522,15 +522,6 @@ class Python2Parser(PythonParser):
|
||||
|
||||
if lhs in ('aug_assign1', 'aug_assign2') and ast[0] and ast[0][0] == 'and':
|
||||
return True
|
||||
elif lhs == '_stmts':
|
||||
for i, stmt in enumerate(ast):
|
||||
if stmt == '_stmts':
|
||||
stmt = stmt[0]
|
||||
assert stmt == 'stmt'
|
||||
if stmt[0] == 'return':
|
||||
return i+1 != len(ast)
|
||||
pass
|
||||
return False
|
||||
return False
|
||||
|
||||
class Python2ParserSingle(Python2Parser, PythonParserSingle):
|
||||
|
Reference in New Issue
Block a user