-
-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code after a tree-transformation phase has the wrong indent. #200
Comments
Tree transformation hasn''t been done yet, so this is not related to that, except that it might be simplified by that transformation were it to exist. A more elegant way to handle this would be via the work in https://github.com/rocky/python-control-flow Want to try integrating that into this project? |
You are right. I was only searching for a name for such code (maybe switch is a better name) Thanks for the fast bugfix, but the problem is not completely solved (see the bottom example and output). I think fixing bugs in uncompyle6 is more important than making the code beautiful. Example: def obj(b):
if b == 1:
b = 5
elif b == 2:
pass
else:
b = 5
return b
import uncompyle6, io, sys, IPython
print('sys.version_info', sys.version_info)
print('uncompyle6.version.VERSION', uncompyle6.version.VERSION)
version = float('{}.{}'.format(sys.version_info.major, sys.version_info.minor))
s = io.StringIO()
_ = uncompyle6.deparse_code(version, obj.__code__, out=s)
code = s.getvalue()
IPython.display.display(IPython.display.Code(code, language='python')) Output: (Return indent is again wrong) sys.version_info sys.version_info(major=3, minor=6, micro=3, releaselevel='final', serial=0)
uncompyle6.version.VERSION 3.2.5
if b == 1:
b = 5
else:
if b == 2:
pass
else:
b = 5
return b |
From current git sources, I am not seeing the results you report. A possible reason is that you are not using the current git sources. Compare with the below and especially look for
|
Sorry, I forgot to mention, that I used a new example. def testit(b):
if b == 1:
b = 5
elif b == 2:
pass # <----- only a pass in this branch
else:
b = 5
return b |
Hey, now that I've shown you two ways that this might be handled, why don't you try to see how to extend the code to handle? |
ok, I will try to solve this. |
Description
Code after a "tree-transformation phase" (see #183) has the wrong indent.
How to Reproduce
Toy example code:
Output from my anaconda 3.6:
Output from my python 3.7:
Expected behavior
The
return
in the last line should not have an indent.Environment
Uncompyle6: 3.2.5
Python: 3.6.3 and 3.7.0
OS: Ubuntu 16.04
The text was updated successfully, but these errors were encountered: