summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-04-10 04:23:18 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-04-10 04:23:18 (GMT)
commit00109c9bd3b5c14e8281addc79a79fda3c310806 (patch)
treeb22473564fd785adc8837110ac81d91ed91f34f6 /Lib
parentda952f3ff43aad1a4602b1bf6e93fd24f0a159f6 (diff)
downloadcpython-00109c9bd3b5c14e8281addc79a79fda3c310806.zip
cpython-00109c9bd3b5c14e8281addc79a79fda3c310806.tar.gz
cpython-00109c9bd3b5c14e8281addc79a79fda3c310806.tar.bz2
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 bc084e9..e667bcd 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 2e5af45..9c5463a 100644
--- a/Lib/lib2to3/tests/test_parser.py
+++ b/Lib/lib2to3/tests/test_parser.py
@@ -50,6 +50,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")