Skip to content

Conversation

@kichik
Copy link
Contributor

@kichik kichik commented Oct 15, 2013

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.

The following code tries to return a value from an `except` block but fails with an assertion.

```python
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:

```python
AssertionError:              21 RETURN_VALUE
```

The suggested patch simply adds support for `return` and seems to work. It results in valid AST.
@stuaxo
Copy link
Contributor

stuaxo commented Feb 7, 2021

Hi
@srossross any chance of merging this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants