You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Handle Python 3.4 MAKE_CLOSURE fns ...
Is done just like Python 3.3
This commit is contained in:
BIN
test/bytecode_3.3_run/02_make_closure.pyc
Normal file
BIN
test/bytecode_3.3_run/02_make_closure.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.4_run/02_make_closure.pyc
Normal file
BIN
test/bytecode_3.4_run/02_make_closure.pyc
Normal file
Binary file not shown.
18
test/simple_source/bug34/02_make_closure.py
Normal file
18
test/simple_source/bug34/02_make_closure.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Related to #426
|
||||||
|
|
||||||
|
# This file is RUNNABLE!
|
||||||
|
"""This program is self-checking!"""
|
||||||
|
|
||||||
|
a = 5
|
||||||
|
class MakeClosureTest():
|
||||||
|
# This function uses MAKE_CLOSURE with annotation args
|
||||||
|
def __init__(self, dev: str, b: bool):
|
||||||
|
super().__init__()
|
||||||
|
self.dev = dev
|
||||||
|
self.b = b
|
||||||
|
self.a = a
|
||||||
|
|
||||||
|
x = MakeClosureTest("dev", True)
|
||||||
|
assert x.dev == "dev"
|
||||||
|
assert x.b == True
|
||||||
|
assert x.a == 5
|
@@ -845,18 +845,18 @@ class Python3Parser(PythonParser):
|
|||||||
|
|
||||||
elif opname in ("BUILD_CONST_LIST", "BUILD_CONST_DICT", "BUILD_CONST_SET"):
|
elif opname in ("BUILD_CONST_LIST", "BUILD_CONST_DICT", "BUILD_CONST_SET"):
|
||||||
if opname == "BUILD_CONST_DICT":
|
if opname == "BUILD_CONST_DICT":
|
||||||
rule = f"""
|
rule = """
|
||||||
add_consts ::= ADD_VALUE*
|
add_consts ::= ADD_VALUE*
|
||||||
const_list ::= COLLECTION_START add_consts {opname}
|
const_list ::= COLLECTION_START add_consts %s
|
||||||
dict ::= const_list
|
dict ::= const_list
|
||||||
expr ::= dict
|
expr ::= dict
|
||||||
"""
|
""" % opname
|
||||||
else:
|
else:
|
||||||
rule = f"""
|
rule = """
|
||||||
add_consts ::= ADD_VALUE*
|
add_consts ::= ADD_VALUE*
|
||||||
const_list ::= COLLECTION_START add_consts {opname}
|
const_list ::= COLLECTION_START add_consts %s
|
||||||
expr ::= const_list
|
expr ::= const_list
|
||||||
"""
|
""" % opname
|
||||||
self.addRule(rule, nop_func)
|
self.addRule(rule, nop_func)
|
||||||
|
|
||||||
elif opname_base in (
|
elif opname_base in (
|
||||||
@@ -1178,7 +1178,9 @@ class Python3Parser(PythonParser):
|
|||||||
"pos_arg " * args_pos,
|
"pos_arg " * args_pos,
|
||||||
opname,
|
opname,
|
||||||
)
|
)
|
||||||
elif self.version == (3, 3):
|
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||||
|
|
||||||
|
elif (3, 3) <= self.version < (3, 5):
|
||||||
if annotate_args > 0:
|
if annotate_args > 0:
|
||||||
rule = (
|
rule = (
|
||||||
"mkfunc_annotate ::= %s%s%sannotate_tuple load_closure LOAD_CODE LOAD_STR %s"
|
"mkfunc_annotate ::= %s%s%sannotate_tuple load_closure LOAD_CODE LOAD_STR %s"
|
||||||
@@ -1195,8 +1197,10 @@ class Python3Parser(PythonParser):
|
|||||||
"pos_arg " * args_pos,
|
"pos_arg " * args_pos,
|
||||||
opname,
|
opname,
|
||||||
)
|
)
|
||||||
|
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||||
|
|
||||||
elif self.version >= (3, 4):
|
|
||||||
|
if self.version >= (3, 4):
|
||||||
if not self.is_pypy:
|
if not self.is_pypy:
|
||||||
load_op = "LOAD_STR"
|
load_op = "LOAD_STR"
|
||||||
else:
|
else:
|
||||||
@@ -1221,7 +1225,7 @@ class Python3Parser(PythonParser):
|
|||||||
opname,
|
opname,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||||
|
|
||||||
if args_kw == 0:
|
if args_kw == 0:
|
||||||
rule = "mkfunc ::= %sload_closure load_genexpr %s" % (
|
rule = "mkfunc ::= %sload_closure load_genexpr %s" % (
|
||||||
|
Reference in New Issue
Block a user