diff --git a/uncompyle6/semantics/gencomp.py b/uncompyle6/semantics/gencomp.py index fa94e63c..6341d6da 100644 --- a/uncompyle6/semantics/gencomp.py +++ b/uncompyle6/semantics/gencomp.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ -Generators and comprehenison functions +Generators and comprehension functions """ @@ -185,7 +185,13 @@ class ComprehensionMixin: self.preorder(tree[iter_index]) self.prec = p - def comprehension_walk_newer(self, node, iter_index: int, code_index: int = -5): + def comprehension_walk_newer( + self, + node, + iter_index: Optional[int], + code_index: int = -5, + collection_node=None, + ): """Non-closure-based comprehensions the way they are done in Python3 and some Python 2.7. Note: there are also other set comprehensions. """ diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 16881c00..5bf65394 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1541,7 +1541,7 @@ class SourceWalker(GenericASTTraversal, ComprehensionMixin): def n_list(self, node): """ - prettyprint a list or tuple + prettyprint a dict, list, set or tuple. """ p = self.prec self.prec = PRECEDENCE["yield"] - 1 @@ -1564,6 +1564,12 @@ class SourceWalker(GenericASTTraversal, ComprehensionMixin): if lastnodetype.startswith("BUILD_LIST"): self.write("[") endchar = "]" + elif lastnodetype.startswith("BUILD_MAP_UNPACK"): + self.write("{*") + endchar = "}" + elif lastnodetype.startswith("BUILD_SET"): + self.write("{") + endchar = "}" elif lastnodetype.startswith("BUILD_TUPLE"): # Tuples can appear places that can NOT # have parenthesis around them, like array @@ -1582,12 +1588,6 @@ class SourceWalker(GenericASTTraversal, ComprehensionMixin): endchar = ")" pass - elif lastnodetype.startswith("BUILD_SET"): - self.write("{") - endchar = "}" - elif lastnodetype.startswith("BUILD_MAP_UNPACK"): - self.write("{*") - endchar = "}" elif lastnodetype.startswith("ROT_TWO"): self.write("(") endchar = ")"