summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/compiler/transformer.py6
-rw-r--r--Lib/test/test_compiler.py5
2 files changed, 7 insertions, 4 deletions
diff --git a/Lib/compiler/transformer.py b/Lib/compiler/transformer.py
index eed9ce9..800461c 100644
--- a/Lib/compiler/transformer.py
+++ b/Lib/compiler/transformer.py
@@ -408,11 +408,11 @@ class Transformer:
return Discard(expr, lineno=expr.lineno)
def yield_expr(self, nodelist):
- if len(nodelist)>1:
- value = nodelist[1]
+ if len(nodelist) > 1:
+ value = self.com_node(nodelist[1])
else:
value = Const(None)
- return Yield(self.com_node(value), lineno=nodelist[0][2])
+ return Yield(value, lineno=nodelist[0][2])
def raise_stmt(self, nodelist):
# raise: [test [',' test [',' test]]]
diff --git a/Lib/test/test_compiler.py b/Lib/test/test_compiler.py
index 6ec71ed..5e7b15c 100644
--- a/Lib/test/test_compiler.py
+++ b/Lib/test/test_compiler.py
@@ -20,7 +20,7 @@ class CompilerTest(unittest.TestCase):
for basename in os.listdir(dir):
if not basename.endswith(".py"):
continue
- if not TEST_ALL and random() < 0.98 and basename != "test_with.py":
+ if not TEST_ALL and random() < 0.98:
continue
path = os.path.join(dir, basename)
if test.test_support.verbose:
@@ -43,6 +43,9 @@ class CompilerTest(unittest.TestCase):
def testNewClassSyntax(self):
compiler.compile("class foo():pass\n\n","<string>","exec")
+ def testYieldExpr(self):
+ compiler.compile("def g(): yield\n\n", "<string>", "exec")
+
def testLineNo(self):
# Test that all nodes except Module have a correct lineno attribute.
filename = __file__