Meta
Meta copied to clipboard
Fix `return` in `except`
The following code tries to return a value from an except block but fails with an assertion.
import meta
def f(x):
try:
return x
except:
return x + 1 # <== offender
f_ast = meta.decompiler.decompile_func(f)
meta.asttools.print_ast(f_ast)
print meta.dump_python_source(f_ast)
It results in the following assertion:
AssertionError: 21 RETURN_VALUE
The suggested patch simply adds support for return and seems to work. It results in valid AST.
Hi @srossross any chance of merging this ?