Error of "if if else" expr sequence
Description
Error of "if if else" expr sequence
How to Reproduce
here is the source code test.py:
a = 1
b = 1
if a:
print("a")
if b:
print("b")
else:
print("else")
then compile it with:
python3 -m compileall -b test.py
and decompile it
uncompyle6 test.pyc >test_dec.py
the output is:
a = 1
b = 1
if a:
print('a')
elif b:
print('b')
else:
print('else')
the decompiled code is quite different from the origin code if run the code, it will print:
$ python3 test.py
a
b
$ python3 test_dec.py
a
Expected behavior
expected decompiled code may look like this:
a = 1
b = 1
if a:
print("a")
if b:
print("b")
else:
print("else")
Environment
this bug can be repeated in such environments:
Ubuntu 20.04
Python 3.8.5 (default, May 27 2021, 13:30:53) [GCC 9.3.0] on linux
uncompyle6 3.7.4 from pip
or
Ubuntu 18.04
Python 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0]
uncompyle6 3.7.4 from pip
Additional Environment or Context
This bug does not exist in decompile3, but decompile3 cannot handler python3.6 bytecode.
Please look at the information in https://github.com/rocky/python-uncompyle6/issues/new?&template=bug-report.md especially the "Environment" sections. Also, have looked to see if this has been reported before?
Please look at the information in https://github.com/rocky/python-uncompyle6/issues/new?&template=bug-report.md especially the "Environment" sections. Also, have looked to see if this has been reported before?
I've updated the bug-report. Sorry for the inconvenience. I've looked through all opened issues and have not seen other reports.