uncompyle2
uncompyle2 copied to clipboard
assert statement not recognized
Code with assert statements gets turned into non valid python code.
$ cat test_assert.py assert isinstance(1, int)
$ uncompyle2 test_assert.pyc raise isinstance(1, int) or AssertionError
$ python test_assert_dis.py
Traceback (most recent call last):
File "test_assert_dis.py", line 1, in
Problem: Due to different matching parser rules, LOAD_ASSERT is getting swallowed by raise- or if-statements, which results in syntactically wrong output or wrong indentation. Solution: LOAD_ASSERT shouldn't be an expression, because it is already handled in "assert" and "assert2" rules. See pull request #24
I have to test this solution! It seems ok, but I know that assert is handled differently between python version eg 2.5, 2.6, 2.7 bytecode