Python 3.6+ specialization

This commit is contained in:
rocky
2021-11-03 02:23:19 -04:00
parent 6af63deaa3
commit f6f0e344d0
12 changed files with 47 additions and 131 deletions

View File

@@ -39,14 +39,10 @@ from copy import copy
from xdis import code2num, iscode, op_has_argument, instruction_size
from xdis.bytecode import _get_const_info
from xdis.version_info import PYTHON3
if PYTHON3:
from sys import intern
from uncompyle6.scanner import Scanner, Token
from sys import intern
class Scanner2(Scanner):
def __init__(self, version, show_asm=None, is_pypy=False):
@@ -147,10 +143,7 @@ class Scanner2(Scanner):
In Python2 this always the operand value shifted 16 bits since
the operand is always 2 bytes. In Python 3.6+ this changes to one byte.
"""
if PYTHON3:
return arg << 16
else:
return arg << long(16)
return arg << 16
@staticmethod
def unmangle_name(name, classname):
@@ -1428,20 +1421,3 @@ class Scanner2(Scanner):
instr_offsets = filtered
filtered = []
return instr_offsets
if __name__ == "__main__":
from uncompyle6 import PYTHON_VERSION
if 2.0 <= PYTHON_VERSION < 3.0:
import inspect
co = inspect.currentframe().f_code
from uncompyle6 import PYTHON_VERSION
tokens, customize = Scanner2(PYTHON_VERSION).ingest(co)
for t in tokens:
print(t)
else:
print("Need to be Python 2.x to demo; I am %s." % PYTHON_VERSION)
pass