scanner32.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Copyright (c) 2015-2017, 2021-2022 by Rocky Bernstein
  2. """
  3. Python 3.2 bytecode decompiler scanner.
  4. Does some additional massaging of xdis-disassembled instructions to
  5. make things easier for decompilation.
  6. This sets up opcodes Python's 3.2 and calls a generalized
  7. scanner routine for Python 3.
  8. """
  9. from __future__ import print_function
  10. # bytecode verification, verify(), uses JUMP_OPs from here
  11. from xdis.opcodes import opcode_32 as opc
  12. JUMP_OPS = opc.JUMP_OPS
  13. from uncompyle6.scanners.scanner3 import Scanner3
  14. class Scanner32(Scanner3):
  15. def __init__(self, show_asm=None, is_pypy=False):
  16. Scanner3.__init__(self, (3, 2), show_asm, is_pypy)
  17. return
  18. pass
  19. if __name__ == "__main__":
  20. from xdis.version_info import PYTHON_VERSION_TRIPLE, version_tuple_to_str
  21. if PYTHON_VERSION_TRIPLE[:2] == (3, 2):
  22. import inspect
  23. co = inspect.currentframe().f_code # type: ignore
  24. tokens, customize = Scanner32().ingest(co)
  25. for t in tokens:
  26. print(t.format())
  27. pass
  28. else:
  29. print("Need to be Python 3.2 to demo; I am version %s" % version_tuple_to_str())