Skip to content
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

list comprehension with if/else #8

Open
rocky opened this issue Jun 30, 2019 · 1 comment
Open

list comprehension with if/else #8

rocky opened this issue Jun 30, 2019 · 1 comment

Comments

@rocky
Copy link

rocky commented Jun 30, 2019

decompiling compiled:

def lc(fields):
    flds = [f for f in fields if (f.compare if f.hash is None else f.hash)]

gives:

$ python unpyc37/unpyc3.py /tmp/cbug2-3.7.pyc
Traceback (most recent call last):
  File "unpyc37/unpyc3.py", line 2907, in <module>
    print(decompile(sys.argv[1]))
  File "unpyc37/unpyc3.py", line 1505, in __str__
    self.display(istr)
  File "unpyc37/unpyc3.py", line 1511, in display
    stmt.display(indent)
  File "unpyc37/unpyc3.py", line 1335, in display
    self.display_undecorated(indent)
  File "unpyc37/unpyc3.py", line 1361, in display_undecorated
    self.code.get_suite().display(indent + 1)
  File "unpyc37/unpyc3.py", line 1511, in display
    stmt.display(indent)
  File "unpyc37/unpyc3.py", line 1164, in display
    indent.write(" = ".join(map(str, self.chain)))
  File "unpyc37/unpyc3.py", line 1028, in __str__
    return self.pattern.format(suite.gen_display())
  File "unpyc37/unpyc3.py", line 1518, in gen_display
    return self[0].gen_display(seq)
  File "unpyc37/unpyc3.py", line 1314, in gen_display
    return self.body.gen_display(seq + (s,))
  File "unpyc37/unpyc3.py", line 1517, in gen_display
    raise Exception('There should only be one statement in a generator.')
Exception: There should only be one statement in a generator.
@rocky
Copy link
Author

rocky commented Jun 30, 2019

Should also add that self here is:

'if f.hash is None:\n if f.compare:\n f\nelif f.hash:\n f\nf'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant