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

chained comparisons #5

Open
rocky opened this issue May 24, 2019 · 1 comment
Open

chained comparisons #5

rocky opened this issue May 24, 2019 · 1 comment

Comments

@rocky
Copy link

rocky commented May 24, 2019

This program:

def chained_compare_b(a, obj):
    if a:
        if -0x80000000 <= obj <= 0x7fffffff:
            return 5

chained_compare_b(True, 0x0)

when compiled and decompiled with unpyc37 gives:

Traceback (most recent call last):
  File "unpyc37/unpyc3.py", line 2899, 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 433, in get_suite
    dec.run()
  File "unpyc37/unpyc3.py", line 1594, in run
    new_addr = method(*args)
  File "unpyc37/unpyc3.py", line 2620, in POP_JUMP_IF_FALSE
    return self.POP_JUMP_IF(addr, target, truthiness=False)
  File "unpyc37/unpyc3.py", line 2447, in POP_JUMP_IF
    c = c.chain(cond)
AttributeError: 'PyName' object has no attribute 'chain'
@rocky
Copy link
Author

rocky commented Jun 30, 2019

Similar is:

digit = 1
if isinstance(digit, int) and 0 <= digit <= 9:
    pass

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