summaryrefslogtreecommitdiff
path: root/as_string.py
diff options
context:
space:
mode:
authorJulien Cristau <julien.cristau@logilab.fr>2013-06-20 15:45:35 +0200
committerJulien Cristau <julien.cristau@logilab.fr>2013-06-20 15:45:35 +0200
commitf816bceffc7c43c049773223f94b776961fd3e78 (patch)
treea325fe54a04100b89d99e66c32f59826df27114f /as_string.py
parent3630cf510922ef1afd15ecf00bbf6e82adcd41b4 (diff)
downloadastroid-git-f816bceffc7c43c049773223f94b776961fd3e78.tar.gz
Handle python3.3's With nodes
Change With nodes to have a list of (expr, var) items as in python 3.3's ast.
Diffstat (limited to 'as_string.py')
-rw-r--r--as_string.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/as_string.py b/as_string.py
index 360e9bbe..fcff19eb 100644
--- a/as_string.py
+++ b/as_string.py
@@ -409,10 +409,10 @@ class AsStringVisitor(object):
def visit_with(self, node): # 'with' without 'as' is possible
"""return an astroid.With node as string"""
- as_var = node.vars and " as (%s)" % (node.vars.accept(self)) or ""
- withs = 'with (%s)%s:\n%s' % (node.expr.accept(self), as_var,
- self._stmt_list( node.body))
- return withs
+ items = ', '.join(('(%s)' % expr.accept(self)) +
+ (vars and ' as (%s)' % (vars.accept(self)) or '')
+ for expr, vars in node.items)
+ return 'with %s:\n%s' % (items, self._stmt_list( node.body))
def visit_yield(self, node):
"""yield an ast.Yield node as string"""