You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
MAKE_FUNCTION_8 -> MAKE_FUNCTION_CLOSURE
Clarity is important.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
# Python 3.6, uses rule:
|
# Python 3.6, uses rule:
|
||||||
# genexpr ::= load_closure load_genexpr LOAD_CONST
|
# genexpr ::= load_closure load_genexpr LOAD_CONST
|
||||||
# MAKE_FUNCTION_8 expr GET_ITER CALL_FUNCTION_1
|
# MAKE_FUNCTION_CLOSURE expr GET_ITER CALL_FUNCTION_1
|
||||||
def __sub__(self, other): # SList()-other
|
def __sub__(self, other): # SList()-other
|
||||||
return self.__class__(i for i in self if i not in other)
|
return self.__class__(i for i in self if i not in other)
|
||||||
|
@@ -4,8 +4,8 @@ def __init__(self, msg = None, digestmod = None):
|
|||||||
self.digest_cons = lambda d='': digestmod.new(d)
|
self.digest_cons = lambda d='': digestmod.new(d)
|
||||||
|
|
||||||
# From Python 3.6 functools.py
|
# From Python 3.6 functools.py
|
||||||
# Bug was handling lambda for MAKE_FUNCTION_8 (closure)
|
# Bug was handling lambda for MAKE_FUNCTION_CLOSURE (closure)
|
||||||
# vs to MAKE_FUNCTION_9 (pos_args + closure)
|
# vs to MAKE_FUNCTION_CLOSURE_POS (pos_args + closure)
|
||||||
def bug():
|
def bug():
|
||||||
def register(cls, func=None):
|
def register(cls, func=None):
|
||||||
return lambda f: register(cls, f)
|
return lambda f: register(cls, f)
|
||||||
|
@@ -220,19 +220,19 @@ class Python36Parser(Python35Parser):
|
|||||||
formatted_value2 ::= expr expr FORMAT_VALUE_ATTR
|
formatted_value2 ::= expr expr FORMAT_VALUE_ATTR
|
||||||
"""
|
"""
|
||||||
self.add_unique_doc_rules(rules_str, customize)
|
self.add_unique_doc_rules(rules_str, customize)
|
||||||
elif opname == 'MAKE_FUNCTION_8':
|
elif opname == 'MAKE_FUNCTION_CLOSURE':
|
||||||
if 'LOAD_DICTCOMP' in self.seen_ops:
|
if 'LOAD_DICTCOMP' in self.seen_ops:
|
||||||
# Is there something general going on here?
|
# Is there something general going on here?
|
||||||
rule = """
|
rule = """
|
||||||
dict_comp ::= load_closure LOAD_DICTCOMP LOAD_STR
|
dict_comp ::= load_closure LOAD_DICTCOMP LOAD_STR
|
||||||
MAKE_FUNCTION_8 expr
|
MAKE_FUNCTION_CLOSURE expr
|
||||||
GET_ITER CALL_FUNCTION_1
|
GET_ITER CALL_FUNCTION_1
|
||||||
"""
|
"""
|
||||||
self.addRule(rule, nop_func)
|
self.addRule(rule, nop_func)
|
||||||
elif 'LOAD_SETCOMP' in self.seen_ops:
|
elif 'LOAD_SETCOMP' in self.seen_ops:
|
||||||
rule = """
|
rule = """
|
||||||
set_comp ::= load_closure LOAD_SETCOMP LOAD_STR
|
set_comp ::= load_closure LOAD_SETCOMP LOAD_STR
|
||||||
MAKE_FUNCTION_8 expr
|
MAKE_FUNCTION_CLOSURE expr
|
||||||
GET_ITER CALL_FUNCTION_1
|
GET_ITER CALL_FUNCTION_1
|
||||||
"""
|
"""
|
||||||
self.addRule(rule, nop_func)
|
self.addRule(rule, nop_func)
|
||||||
|
@@ -1205,19 +1205,19 @@ class Python37Parser(Python37BaseParser):
|
|||||||
formatted_value2 ::= expr expr FORMAT_VALUE_ATTR
|
formatted_value2 ::= expr expr FORMAT_VALUE_ATTR
|
||||||
"""
|
"""
|
||||||
self.add_unique_doc_rules(rules_str, customize)
|
self.add_unique_doc_rules(rules_str, customize)
|
||||||
elif opname == "MAKE_FUNCTION_8":
|
elif opname == "MAKE_FUNCTION_CLOSURE":
|
||||||
if "LOAD_DICTCOMP" in self.seen_ops:
|
if "LOAD_DICTCOMP" in self.seen_ops:
|
||||||
# Is there something general going on here?
|
# Is there something general going on here?
|
||||||
rule = """
|
rule = """
|
||||||
dict_comp ::= load_closure LOAD_DICTCOMP LOAD_STR
|
dict_comp ::= load_closure LOAD_DICTCOMP LOAD_STR
|
||||||
MAKE_FUNCTION_8 expr
|
MAKE_FUNCTION_CLOSURE expr
|
||||||
GET_ITER CALL_FUNCTION_1
|
GET_ITER CALL_FUNCTION_1
|
||||||
"""
|
"""
|
||||||
self.addRule(rule, nop_func)
|
self.addRule(rule, nop_func)
|
||||||
elif "LOAD_SETCOMP" in self.seen_ops:
|
elif "LOAD_SETCOMP" in self.seen_ops:
|
||||||
rule = """
|
rule = """
|
||||||
set_comp ::= load_closure LOAD_SETCOMP LOAD_STR
|
set_comp ::= load_closure LOAD_SETCOMP LOAD_STR
|
||||||
MAKE_FUNCTION_8 expr
|
MAKE_FUNCTION_CLOSURE expr
|
||||||
GET_ITER CALL_FUNCTION_1
|
GET_ITER CALL_FUNCTION_1
|
||||||
"""
|
"""
|
||||||
self.addRule(rule, nop_func)
|
self.addRule(rule, nop_func)
|
||||||
|
@@ -947,19 +947,19 @@ class Python37BaseParser(PythonParser):
|
|||||||
)
|
)
|
||||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||||
|
|
||||||
elif opname == "MAKE_FUNCTION_8":
|
elif opname == "MAKE_FUNCTION_CLOSURE":
|
||||||
if "LOAD_DICTCOMP" in self.seen_ops:
|
if "LOAD_DICTCOMP" in self.seen_ops:
|
||||||
# Is there something general going on here?
|
# Is there something general going on here?
|
||||||
rule = """
|
rule = """
|
||||||
dict_comp ::= load_closure LOAD_DICTCOMP LOAD_STR
|
dict_comp ::= load_closure LOAD_DICTCOMP LOAD_STR
|
||||||
MAKE_FUNCTION_8 expr
|
MAKE_FUNCTION_CLOSURE expr
|
||||||
GET_ITER CALL_FUNCTION_1
|
GET_ITER CALL_FUNCTION_1
|
||||||
"""
|
"""
|
||||||
self.addRule(rule, nop_func)
|
self.addRule(rule, nop_func)
|
||||||
elif "LOAD_SETCOMP" in self.seen_ops:
|
elif "LOAD_SETCOMP" in self.seen_ops:
|
||||||
rule = """
|
rule = """
|
||||||
set_comp ::= load_closure LOAD_SETCOMP LOAD_STR
|
set_comp ::= load_closure LOAD_SETCOMP LOAD_STR
|
||||||
MAKE_FUNCTION_8 expr
|
MAKE_FUNCTION_CLOSURE expr
|
||||||
GET_ITER CALL_FUNCTION_1
|
GET_ITER CALL_FUNCTION_1
|
||||||
"""
|
"""
|
||||||
self.addRule(rule, nop_func)
|
self.addRule(rule, nop_func)
|
||||||
|
@@ -391,7 +391,13 @@ class Scanner3(Scanner):
|
|||||||
if self.version >= (3, 6):
|
if self.version >= (3, 6):
|
||||||
# 3.6+ doesn't have MAKE_CLOSURE, so opname == 'MAKE_FUNCTION'
|
# 3.6+ doesn't have MAKE_CLOSURE, so opname == 'MAKE_FUNCTION'
|
||||||
flags = argval
|
flags = argval
|
||||||
opname = "MAKE_FUNCTION_%d" % (flags)
|
# FIXME: generalize this
|
||||||
|
if flags == 8:
|
||||||
|
opname = "MAKE_FUNCTION_CLOSURE"
|
||||||
|
elif flags == 9:
|
||||||
|
opname = "MAKE_FUNCTION_CLOSURE_POS"
|
||||||
|
else:
|
||||||
|
opname = f"MAKE_FUNCTION_{flags}"
|
||||||
attr = []
|
attr = []
|
||||||
for flag in self.MAKE_FUNCTION_FLAGS:
|
for flag in self.MAKE_FUNCTION_FLAGS:
|
||||||
bit = flags & 1
|
bit = flags & 1
|
||||||
|
Reference in New Issue
Block a user