python2.6-compiler-package-micropython

Changeset

25:abb8f39e4c53
2013-11-15 Paul Boddie raw files shortlog changelog graph Support tuple parameters in the serialised output. Fixed "with" serialisation.
compiler/ast.py (file)
     1.1 --- a/compiler/ast.py	Sun Oct 27 01:12:35 2013 +0200
     1.2 +++ b/compiler/ast.py	Fri Nov 15 22:03:19 2013 +0100
     1.3 @@ -952,7 +952,8 @@
     1.4          return "%sdef %s(%s):%s%s\n" % (
     1.5              self.decorators and "%s\n" % "\n".join([("@%s" % decorator) for decorator in self.decorators]) or "",
     1.6              self.name,
     1.7 -            ", ".join(parameters),
     1.8 +            # NOTE: Handling tuples using str.
     1.9 +            ", ".join(map(str, parameters)),
    1.10              self.doc and "\n\n\t%s\n" % docstring(self.doc) or "",
    1.11              indent("\n%s" % self.code)
    1.12              )
    1.13 @@ -1270,7 +1271,8 @@
    1.14  
    1.15      def __str__(self):
    1.16          parameters = decode_function(self)
    1.17 -        return "lambda %s: %s" % (", ".join(parameters), self.code)
    1.18 +        # NOTE: Handling tuples using str.
    1.19 +        return "lambda %s: %s" % (", ".join(map(str, parameters)), self.code)
    1.20  
    1.21      def visit(self, visitor, *args):
    1.22          return visitor.visitLambda(self, *args)
    1.23 @@ -2068,7 +2070,7 @@
    1.24      def __str__(self):
    1.25          return "with %s%s:%s" % (
    1.26              self.expr,
    1.27 -            self.vars and " as %s" % ", ".join(map(str, self.vars)),
    1.28 +            self.vars and (" as %s" % self.vars) or "",
    1.29              indent("\n%s" % self.body),
    1.30              )
    1.31