You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 08:34:46 +08:00
3.6+ lambda params; add semantic rule customizing for lambdas
This commit is contained in:
BIN
test/bytecode_3.6_run/04_lambda_star_default.pyc
Normal file
BIN
test/bytecode_3.6_run/04_lambda_star_default.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.7_run/04_lambda_star_default.pyc
Normal file
BIN
test/bytecode_3.7_run/04_lambda_star_default.pyc
Normal file
Binary file not shown.
@@ -101,7 +101,6 @@ class PythonParser(GenericASTBuilder):
|
||||
many arguments it has. Often it is not used.
|
||||
"""
|
||||
if rule not in self.new_rules:
|
||||
# print("XXX ", rule) # debug
|
||||
self.new_rules.add(rule)
|
||||
self.addRule(rule, nop_func)
|
||||
customize[opname] = arg_count
|
||||
|
@@ -798,7 +798,7 @@ def make_function3(self, node, is_lambda, nested=1, code_node=None):
|
||||
params.reverse()
|
||||
else:
|
||||
params.append("*%s" % code.co_varnames[argc])
|
||||
if not is_lambda:
|
||||
if not is_lambda or self.version >= 3.6:
|
||||
argc += 1
|
||||
|
||||
# dump parameter list (with default values)
|
||||
|
@@ -484,7 +484,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
else:
|
||||
# We can't comment out like above because there may be a trailing ')'
|
||||
# that needs to be written
|
||||
assert len(node) == 3 and node[2] == "LAMBDA_MARKER"
|
||||
assert len(node) == 3 and node[2] in ("RETURN_VALUE_LAMBDA", "LAMBDA_MARKER")
|
||||
self.preorder(node[0])
|
||||
self.prune()
|
||||
|
||||
@@ -2366,6 +2366,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
p_insts = self.p.insts
|
||||
self.p.insts = self.scanner.insts
|
||||
ast = python_parser.parse(self.p, tokens, customize)
|
||||
self.customize(customize)
|
||||
self.p.insts = p_insts
|
||||
except (python_parser.ParserError, AssertionError) as e:
|
||||
raise ParserError(e, tokens)
|
||||
|
Reference in New Issue
Block a user