aboutsummaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-04-10 00:23:18 -0400
committerBenjamin Peterson <benjamin@python.org>2014-04-10 00:23:18 -0400
commit0654be18b387cbd136bfb62d77849111a954b58b (patch)
tree18bfb8fa836b396f43e28ccf8ec59d2eb6b9ab06 /Lib
parentadd matrix multiplication operator support to 2to3 (diff)
downloadcpython-0654be18b387cbd136bfb62d77849111a954b58b.tar.gz
cpython-0654be18b387cbd136bfb62d77849111a954b58b.tar.bz2
cpython-0654be18b387cbd136bfb62d77849111a954b58b.zip
teach 2to3 about 'yield from'
Diffstat (limited to 'Lib')
-rw-r--r--Lib/lib2to3/Grammar.txt3
-rw-r--r--Lib/lib2to3/tests/test_parser.py7
2 files changed, 9 insertions, 1 deletions
diff --git a/Lib/lib2to3/Grammar.txt b/Lib/lib2to3/Grammar.txt
index bc084e97901..e667bcde69d 100644
--- a/Lib/lib2to3/Grammar.txt
+++ b/Lib/lib2to3/Grammar.txt
@@ -155,4 +155,5 @@ testlist1: test (',' test)*
# not used in grammar, but may appear in "node" passed from Parser to Compiler
encoding_decl: NAME
-yield_expr: 'yield' [testlist]
+yield_expr: 'yield' [yield_arg]
+yield_arg: 'from' test | testlist
diff --git a/Lib/lib2to3/tests/test_parser.py b/Lib/lib2to3/tests/test_parser.py
index 83682b7dc53..b64469ced6e 100644
--- a/Lib/lib2to3/tests/test_parser.py
+++ b/Lib/lib2to3/tests/test_parser.py
@@ -54,6 +54,13 @@ class TestMatrixMultiplication(GrammarTest):
self.validate("a @= b")
+class TestYieldFrom(GrammarTest):
+ def test_matrix_multiplication_operator(self):
+ self.validate("yield from x")
+ self.validate("(yield from x) + y")
+ self.invalid_syntax("yield from")
+
+
class TestRaiseChanges(GrammarTest):
def test_2x_style_1(self):
self.validate("raise")