You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Towards handling CALL_FUNCTION_EX_KW...
more work is needed though
This commit is contained in:
@@ -498,17 +498,11 @@ class Python3Parser(PythonParser):
|
||||
('pos_arg ' * args_pos) +
|
||||
('kwarg ' * args_kw) + kw + token.kind)
|
||||
self.add_unique_rule(rule, token.kind, uniq_param, customize)
|
||||
if self.version >= 3.6 and opname == 'CALL_FUNCTION_EX_KW':
|
||||
rule = ('call36 ::= '
|
||||
'expr build_tuple_unpack_with_call build_map_unpack_with_call '
|
||||
'CALL_FUNCTION_EX_KW_1')
|
||||
self.add_unique_rule(rule, token.kind, uniq_param, customize)
|
||||
rule = 'call ::= call36'
|
||||
else:
|
||||
rule = ('call ::= expr ' +
|
||||
('pos_arg ' * args_pos) +
|
||||
('kwarg ' * args_kw) +
|
||||
'expr ' * nak + token.kind)
|
||||
|
||||
rule = ('call ::= expr ' +
|
||||
('pos_arg ' * args_pos) +
|
||||
('kwarg ' * args_kw) +
|
||||
'expr ' * nak + token.kind)
|
||||
|
||||
self.add_unique_rule(rule, token.kind, uniq_param, customize)
|
||||
if self.version >= 3.5 and seen_GET_AWAITABLE_YIELD_FROM:
|
||||
|
@@ -140,12 +140,17 @@ class Python36Parser(Python35Parser):
|
||||
elif opname == 'CALL_FUNCTION_EX_KW':
|
||||
self.addRule("""expr ::= call_ex_kw
|
||||
expr ::= call_ex_kw2
|
||||
expr ::= call_ex_kw3
|
||||
call_ex_kw ::= expr expr build_map_unpack_with_call
|
||||
CALL_FUNCTION_EX_KW
|
||||
call_ex_kw2 ::= expr
|
||||
build_tuple_unpack_with_call
|
||||
build_map_unpack_with_call
|
||||
CALL_FUNCTION_EX_KW
|
||||
call_ex_kw3 ::= expr
|
||||
tuple
|
||||
expr
|
||||
CALL_FUNCTION_EX_KW
|
||||
""",
|
||||
nop_func)
|
||||
elif opname == 'CALL_FUNCTION_EX':
|
||||
|
@@ -612,6 +612,23 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.prune()
|
||||
self.n_call_ex_kw2 = call_ex_kw2
|
||||
|
||||
def call_ex_kw3(node):
|
||||
self.preorder(node[0])
|
||||
self.write('(')
|
||||
tup = node[1]
|
||||
assert tup == 'tuple'
|
||||
self.call36_tuple(tup)
|
||||
expr = node[2]
|
||||
assert expr == 'expr'
|
||||
if tup[0].attr > 0:
|
||||
self.write(', ')
|
||||
self.write('**')
|
||||
self.preorder(expr)
|
||||
self.write(')')
|
||||
self.prune()
|
||||
self.n_call_ex_kw3 = call_ex_kw3
|
||||
|
||||
|
||||
def call36_tuple(node):
|
||||
"""
|
||||
A tuple used in a call, these are like normal tuples but they
|
||||
|
Reference in New Issue
Block a user