You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
Improve 3.5+ BUILD_MAP_UNPACK...
And add build_tuple_unpack runtime test from a previous commit. We are far from out of the woods, as there is more to do and we've uncovered more bugs in handling this.
This commit is contained in:
@@ -626,7 +626,7 @@ class Python3Parser(PythonParser):
|
||||
self.addRule(rule, nop_func)
|
||||
rule = 'expr ::= build_list_unpack'
|
||||
self.addRule(rule, nop_func)
|
||||
elif opname_base == 'BUILD_MAP':
|
||||
elif opname_base in ('BUILD_MAP', 'BUILD_MAP_UNPACK'):
|
||||
kvlist_n = "kvlist_%s" % token.attr
|
||||
if opname == 'BUILD_MAP_n':
|
||||
# PyPy sometimes has no count. Sigh.
|
||||
@@ -645,23 +645,21 @@ class Python3Parser(PythonParser):
|
||||
# FIXME: Use the attr
|
||||
# so this doesn't run into exponential parsing time.
|
||||
if opname.startswith('BUILD_MAP_UNPACK'):
|
||||
# FIXME: start here
|
||||
# rule = "%s ::= %s %s" % (kvlist_n, 'expr ' * (token.attr*2), opname)
|
||||
rule = kvlist_n + ' ::= ' + 'expr ' * (token.attr*2)
|
||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||
rule = 'dict_entry ::= ' + 'expr ' * (token.attr*2)
|
||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||
rule = 'dict ::= %s' % ('dict_entry ' * token.attr)
|
||||
self.addRule(rule, nop_func)
|
||||
|
||||
# FIXME: start here. The LHS should be unmap_dict, not dict.
|
||||
# FIXME: really we need a combination of dict_entry-like things.
|
||||
# It just so happens the most common case is not to mix
|
||||
# dictionary comphensions with dictionary, elements
|
||||
if self.seen_LOAD_DICTCOMP:
|
||||
rule = 'dict ::= %s%s' % ('dict_comp ' * token.attr, opname)
|
||||
self.addRule(rule, nop_func)
|
||||
|
||||
rule = 'unmap_dict ::= %s%s' % (('dict ' * token.attr), opname)
|
||||
rule = """
|
||||
expr ::= unmap_dict
|
||||
unmap_dict ::= %s%s
|
||||
""" % ('expr ' * token.attr, opname)
|
||||
else:
|
||||
rule = "%s ::= %s %s" % (kvlist_n, 'expr ' * (token.attr*2), opname)
|
||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||
|
Reference in New Issue
Block a user