You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 08:49:51 +08:00
Python version comparison adjustments
This commit is contained in:
@@ -20,12 +20,11 @@ JUMP_OPS = opc.JUMP_OPS
|
|||||||
class Scanner36(Scanner3):
|
class Scanner36(Scanner3):
|
||||||
|
|
||||||
def __init__(self, show_asm=None, is_pypy=False):
|
def __init__(self, show_asm=None, is_pypy=False):
|
||||||
Scanner3.__init__(self, (3, 6), show_asm, is_pypy)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def ingest(self, co, classname=None, code_objects={}, show_asm=None):
|
def ingest(self, co, classname=None, code_objects={}, show_asm=None):
|
||||||
tokens, customize = Scanner3.ingest(self, co, classname, code_objects, show_asm)
|
tokens, customize = Scanner3.ingest(self, co, classname, code_objects, show_asm)
|
||||||
not_pypy36 = not (self.version == 3.6 and self.is_pypy)
|
not_pypy36 = not (self.version[:2] == (3, 6) and self.is_pypy)
|
||||||
for t in tokens:
|
for t in tokens:
|
||||||
# The lowest bit of flags indicates whether the
|
# The lowest bit of flags indicates whether the
|
||||||
# var-keyword argument is placed at the top of the stack
|
# var-keyword argument is placed at the top of the stack
|
||||||
|
@@ -107,7 +107,7 @@ def customize_for_version3(self, version):
|
|||||||
collections = [node[-3]]
|
collections = [node[-3]]
|
||||||
list_ifs = []
|
list_ifs = []
|
||||||
|
|
||||||
if self.version == (3, 0) and n != "list_iter":
|
if self.version[:2] == (3, 0) and n != "list_iter":
|
||||||
# FIXME 3.0 is a snowflake here. We need
|
# FIXME 3.0 is a snowflake here. We need
|
||||||
# special code for this. Not sure if this is totally
|
# special code for this. Not sure if this is totally
|
||||||
# correct.
|
# correct.
|
||||||
@@ -204,10 +204,10 @@ def customize_for_version3(self, version):
|
|||||||
self.listcomp_closure3 = listcomp_closure3
|
self.listcomp_closure3 = listcomp_closure3
|
||||||
|
|
||||||
def n_classdef3(node):
|
def n_classdef3(node):
|
||||||
"""Handle "classdef" nonterminal for 3.0 >= version 3.0 <= 3.5
|
"""Handle "classdef" nonterminal for 3.0 >= version 3.0 < 3.6
|
||||||
"""
|
"""
|
||||||
|
|
||||||
assert (3, 0) <= self.version <= (3, 5)
|
assert (3, 0) <= self.version < (3, 6)
|
||||||
|
|
||||||
# class definition ('class X(A,B,C):')
|
# class definition ('class X(A,B,C):')
|
||||||
cclass = self.currentclass
|
cclass = self.currentclass
|
||||||
@@ -220,7 +220,7 @@ def customize_for_version3(self, version):
|
|||||||
# * subclass_code - the code for the subclass body
|
# * subclass_code - the code for the subclass body
|
||||||
subclass_info = None
|
subclass_info = None
|
||||||
if node == "classdefdeco2":
|
if node == "classdefdeco2":
|
||||||
if self.version <= (3, 3):
|
if self.version < (3, 4):
|
||||||
class_name = node[2][0].attr
|
class_name = node[2][0].attr
|
||||||
else:
|
else:
|
||||||
class_name = node[1][2].attr
|
class_name = node[1][2].attr
|
||||||
@@ -233,7 +233,7 @@ def customize_for_version3(self, version):
|
|||||||
assert "mkfunc" == build_class[1]
|
assert "mkfunc" == build_class[1]
|
||||||
mkfunc = build_class[1]
|
mkfunc = build_class[1]
|
||||||
if mkfunc[0] in ("kwargs", "no_kwargs"):
|
if mkfunc[0] in ("kwargs", "no_kwargs"):
|
||||||
if (3, 0) <= self.version <= (3, 2):
|
if (3, 0) <= self.version < (3, 3):
|
||||||
for n in mkfunc:
|
for n in mkfunc:
|
||||||
if hasattr(n, "attr") and iscode(n.attr):
|
if hasattr(n, "attr") and iscode(n.attr):
|
||||||
subclass_code = n.attr
|
subclass_code = n.attr
|
||||||
@@ -416,7 +416,7 @@ def customize_for_version3(self, version):
|
|||||||
# Handling EXTENDED_ARG before MAKE_FUNCTION ...
|
# Handling EXTENDED_ARG before MAKE_FUNCTION ...
|
||||||
i = -1 if node[-2] == "EXTENDED_ARG" else 0
|
i = -1 if node[-2] == "EXTENDED_ARG" else 0
|
||||||
|
|
||||||
if self.version <= (3, 2):
|
if self.version < (3, 3):
|
||||||
code = node[-2 + i]
|
code = node[-2 + i]
|
||||||
elif self.version >= (3, 3) or node[-2] == "kwargs":
|
elif self.version >= (3, 3) or node[-2] == "kwargs":
|
||||||
# LOAD_CONST code object ..
|
# LOAD_CONST code object ..
|
||||||
|
Reference in New Issue
Block a user