Mysterie / uncompyle2

uncompyle2
642 stars 148 forks source link

assert statement not recognized #14

Open FlorianLudwig opened 11 years ago

FlorianLudwig commented 11 years ago

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

frankebersoll commented 9 years ago

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

Mysterie commented 9 years ago

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