scanner31.py 1.0 KB

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