diff --git a/test/simple_source/bug35/01_map_unpack.py b/test/simple_source/bug35/01_map_unpack.py index deac50a0..49b32f95 100644 --- a/test/simple_source/bug35/01_map_unpack.py +++ b/test/simple_source/bug35/01_map_unpack.py @@ -3,3 +3,4 @@ {**{'a': 1, 'b': 2}} {'x': 1, **{'y': 2}} # {'c': 1, {'d': 2}, **{'e': 3}} +[*[]] diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 1b580696..0fbf0e55 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1536,22 +1536,20 @@ class SourceWalker(GenericASTTraversal, object): # will assume that if the text ends in *. last_was_star = self.f.getvalue().endswith('*') + if lastnodetype.startswith('BUILD_LIST'): + self.write('['); endchar = ']' + elif lastnodetype.startswith('BUILD_TUPLE'): + self.write('('); endchar = ')' + elif lastnodetype.startswith('BUILD_SET'): + self.write('{'); endchar = '}' + elif lastnodetype.startswith('ROT_TWO'): + self.write('('); endchar = ')' + else: + raise 'Internal Error: n_build_list expects list or tuple' have_star = False if lastnodetype.endswith('UNPACK'): # FIXME: need to handle range of BUILD_LIST_UNPACK have_star = True - endchar = '' - else: - if lastnodetype.startswith('BUILD_LIST'): - self.write('['); endchar = ']' - elif lastnodetype.startswith('BUILD_TUPLE'): - self.write('('); endchar = ')' - elif lastnodetype.startswith('BUILD_SET'): - self.write('{'); endchar = '}' - elif lastnodetype.startswith('ROT_TWO'): - self.write('('); endchar = ')' - else: - raise 'Internal Error: n_build_list expects list or tuple' flat_elems = [] for elem in node: