# HG changeset patch # User Paul Boddie # Date 1384549399 -3600 # Node ID 98033bfa4034fcfb5c861ab66aa21201a82407de # Parent 6f4e40d6109a1879b6863a852a6b694c49a6bf16 Support tuple parameters in the serialised output. Fixed "with" serialisation. diff -r 6f4e40d6109a -r 98033bfa4034 compiler/ast.py --- a/compiler/ast.py Sun Oct 27 01:12:35 2013 +0200 +++ b/compiler/ast.py Fri Nov 15 22:03:19 2013 +0100 @@ -952,7 +952,8 @@ return "%sdef %s(%s):%s%s\n" % ( self.decorators and "%s\n" % "\n".join([("@%s" % decorator) for decorator in self.decorators]) or "", self.name, - ", ".join(parameters), + # NOTE: Handling tuples using str. + ", ".join(map(str, parameters)), self.doc and "\n\n\t%s\n" % docstring(self.doc) or "", indent("\n%s" % self.code) ) @@ -1270,7 +1271,8 @@ def __str__(self): parameters = decode_function(self) - return "lambda %s: %s" % (", ".join(parameters), self.code) + # NOTE: Handling tuples using str. + return "lambda %s: %s" % (", ".join(map(str, parameters)), self.code) def visit(self, visitor, *args): return visitor.visitLambda(self, *args) @@ -2147,7 +2149,7 @@ def __str__(self): return "with %s%s:%s" % ( self.expr, - self.vars and " as %s" % ", ".join(map(str, self.vars)), + self.vars and (" as %s" % self.vars) or "", indent("\n%s" % self.body), )