mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-11-23 13:09:49 +00:00
parent
47dbc57f3d
commit
03498963d4
BIN
test/bytecode_3.5/01_map_unpack.pyc
Normal file
BIN
test/bytecode_3.5/01_map_unpack.pyc
Normal file
Binary file not shown.
5
test/simple_source/bug35/01_map_unpack.py
Normal file
5
test/simple_source/bug35/01_map_unpack.py
Normal file
@ -0,0 +1,5 @@
|
||||
# Python 3.5+ PEP 448 - Additional Unpacking Generalizations for dictionaries
|
||||
{**{}}
|
||||
{**{'a': 1, 'b': 2}}
|
||||
{'x': 1, **{'y': 2}}
|
||||
# {'c': 1, {'d': 2}, **{'e': 3}}
|
@ -661,7 +661,9 @@ class Python3Parser(PythonParser):
|
||||
if opname != 'BUILD_MAP_WITH_CALL':
|
||||
rule = kvlist_n + ' ::= ' + 'expr ' * (token.attr*2)
|
||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||
rule = "mapexpr ::= %s %s" % (kvlist_n, opname)
|
||||
lhs = 'unmapexpr' if opname == 'BUILD_MAP_UNPACK' else' mapexpr'
|
||||
rule = "%s ::= %s %s" % (lhs, kvlist_n, opname)
|
||||
# print("XXX", rule)
|
||||
|
||||
else:
|
||||
rule = kvlist_n + ' ::= ' + 'expr expr STORE_MAP ' * token.attr
|
||||
|
@ -116,6 +116,8 @@ class Python35Parser(Python34Parser):
|
||||
|
||||
yield_from ::= expr GET_YIELD_FROM_ITER LOAD_CONST YIELD_FROM
|
||||
|
||||
expr ::= unmap_dict
|
||||
expr ::= unmapexpr
|
||||
"""
|
||||
|
||||
def add_custom_rules(self, tokens, customize):
|
||||
@ -134,6 +136,10 @@ class Python35Parser(Python34Parser):
|
||||
rule = 'call_function ::= expr unmapexpr ' + call_token.type
|
||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||
pass
|
||||
elif opname == 'BUILD_MAP_UNPACK':
|
||||
nargs = token.attr % 256
|
||||
rule = "unmap_dict ::= mapexpr " + opname
|
||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||
pass
|
||||
return
|
||||
|
||||
|
@ -338,6 +338,8 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
'%|async with %c:\n%+%c%-', 0, 7),
|
||||
'async_with_as_stmt': (
|
||||
'%|async with %c as %c:\n%+%c%-', 0, 6, 7),
|
||||
'unmap_dict': ( '{**%c}', 0),
|
||||
'unmapexpr': ( '{**%c}', 0),
|
||||
|
||||
})
|
||||
def n_async_call_function(node):
|
||||
|
Loading…
Reference in New Issue
Block a user