diff options
author | Torsten Marek <tmarek@google.com> | 2013-03-27 12:29:00 +0100 |
---|---|---|
committer | Torsten Marek <tmarek@google.com> | 2013-03-27 12:29:00 +0100 |
commit | 73bf62b2dd02a903b98ff0d90f1150a0261a18ba (patch) | |
tree | 13fa67385da7a5a9d64ae2b762c2a2e89291112b /as_string.py | |
parent | 6acc305b9e4d77debf68eb95d9d5f7951d3aa583 (diff) | |
download | astroid-73bf62b2dd02a903b98ff0d90f1150a0261a18ba.tar.gz |
Fix inference for generator methods to correctly handle yields in lambdas. Closes #123068
Diffstat (limited to 'as_string.py')
-rw-r--r-- | as_string.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/as_string.py b/as_string.py index 0a42668..d347861 100644 --- a/as_string.py +++ b/as_string.py @@ -385,7 +385,11 @@ class AsStringVisitor(object): def visit_yield(self, node): """yield an ast.Yield node as string""" yi_val = node.value and (" " + node.value.accept(self)) or "" - return 'yield' + yi_val + expr = 'yield' + yi_val + if node.parent.is_statement: + return expr + else: + return "(%s)" % (expr,) class AsStringVisitor3k(AsStringVisitor): |