You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Work on 3.5+ BUILD_MAP_UNPACK...
bugs still remain, just reduced.
This commit is contained in:
Binary file not shown.
BIN
test/bytecode_3.5_run/01_map_unpack.pyc
Normal file
BIN
test/bytecode_3.5_run/01_map_unpack.pyc
Normal file
Binary file not shown.
@@ -1,9 +1,19 @@
|
|||||||
# Python 3.5+ PEP 448 - Additional Unpacking Generalizations for dictionaries
|
# Python 3.5+ PEP 448 - Additional Unpacking Generalizations for dictionaries
|
||||||
{**{}}
|
# RUNNABLE!
|
||||||
{**{'a': 1, 'b': 2}}
|
b = {**{}}
|
||||||
## {**{'x': 1}, **{'y': 2}}
|
assert b == {}
|
||||||
|
c = {**{'a': 1, 'b': 2}}
|
||||||
|
assert c == {'a': 1, 'b': 2}
|
||||||
|
d = {**{'x': 1}, **{'y': 2}}
|
||||||
|
assert d == {'x': 1, 'y': 2}
|
||||||
# {'c': 1, {'d': 2}, **{'e': 3}}
|
# {'c': 1, {'d': 2}, **{'e': 3}}
|
||||||
[*[]]
|
[*[]]
|
||||||
{**{0:0 for a in b}}
|
|
||||||
## {**{}, **{}}
|
assert {0: 0} == {**{0:0 for a in c}}
|
||||||
## {**{}, **{}, **{}}
|
|
||||||
|
# FIXME: assert deparsing is incorrect for:
|
||||||
|
# {**{}, **{}}
|
||||||
|
# assert {} == {**{}, **{}, **{}}
|
||||||
|
|
||||||
|
# {**{}, **{}, **{}}
|
||||||
|
# assert {} == {**{}, **{}, **{}}
|
||||||
|
@@ -1696,7 +1696,8 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
|
|
||||||
self.indent_more(INDENT_PER_LEVEL)
|
self.indent_more(INDENT_PER_LEVEL)
|
||||||
sep = INDENT_PER_LEVEL[:-1]
|
sep = INDENT_PER_LEVEL[:-1]
|
||||||
self.write('{')
|
if node[0] != 'dict_entry':
|
||||||
|
self.write('{')
|
||||||
line_number = self.line_number
|
line_number = self.line_number
|
||||||
|
|
||||||
if self.version >= 3.0 and not self.is_pypy:
|
if self.version >= 3.0 and not self.is_pypy:
|
||||||
@@ -1778,7 +1779,13 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
if sep.startswith(",\n"):
|
if sep.startswith(",\n"):
|
||||||
self.write(sep[1:])
|
self.write(sep[1:])
|
||||||
pass
|
pass
|
||||||
elif node[-1].kind.startswith('BUILD_MAP_UNPACK'):
|
elif node[0].kind.startswith('dict_entry'):
|
||||||
|
assert self.version >= 3.5
|
||||||
|
template = ("%C", (0, len(node[0]), ", **"))
|
||||||
|
self.template_engine(template, node[0])
|
||||||
|
sep = ''
|
||||||
|
elif (node[-1].kind.startswith('BUILD_MAP_UNPACK')
|
||||||
|
or node[-1].kind.startswith('dict_entry')):
|
||||||
assert self.version >= 3.5
|
assert self.version >= 3.5
|
||||||
# FIXME: I think we can intermingle dict_comp's with other
|
# FIXME: I think we can intermingle dict_comp's with other
|
||||||
# dictionary kinds of things. The most common though is
|
# dictionary kinds of things. The most common though is
|
||||||
@@ -1852,7 +1859,8 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
pass
|
pass
|
||||||
if sep.startswith(",\n"):
|
if sep.startswith(",\n"):
|
||||||
self.write(sep[1:])
|
self.write(sep[1:])
|
||||||
self.write('}')
|
if node[0] != 'dict_entry':
|
||||||
|
self.write('}')
|
||||||
self.indent_less(INDENT_PER_LEVEL)
|
self.indent_less(INDENT_PER_LEVEL)
|
||||||
self.prec = p
|
self.prec = p
|
||||||
self.prune()
|
self.prune()
|
||||||
|
Reference in New Issue
Block a user