uncompyle2 icon indicating copy to clipboard operation
uncompyle2 copied to clipboard

assert statement not recognized

Open FlorianLudwig opened this issue 11 years ago • 2 comments

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 raise isinstance(1, int) or AssertionError TypeError: exceptions must be old-style classes or derived from BaseException, not bool

FlorianLudwig avatar Jul 04 '13 15:07 FlorianLudwig

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

frankebersoll avatar Dec 02 '14 21:12 frankebersoll

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

Mysterie avatar Jun 25 '15 10:06 Mysterie