]> granicus.if.org Git - python/commitdiff
teach 2to3 about 'yield from'
authorBenjamin Peterson <benjamin@python.org>
Thu, 10 Apr 2014 04:23:18 +0000 (00:23 -0400)
committerBenjamin Peterson <benjamin@python.org>
Thu, 10 Apr 2014 04:23:18 +0000 (00:23 -0400)
Lib/lib2to3/Grammar.txt
Lib/lib2to3/tests/test_parser.py
Misc/NEWS

index bc084e97901f0aee582dd7436a583850c842e96f..e667bcde69d037b3ae7951aade0f54e6a13b5b11 100644 (file)
@@ -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
index 2e5af45399a6757349109789a633604d090ae492..9c5463a7c0ff824af3b8a678628c9ca390421ac8 100644 (file)
@@ -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")
index fb06c015ba4510a3b102460722d70be697a0913b..7756e89c3da3831a9ffd9570abdc326d6c9cbd64 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -266,6 +266,8 @@ Library
 Tools/Demos
 -----------
 
+- Add support for ``yield from`` to 2to3.
+
 - Add support for the PEP 465 matrix multiplication operator to 2to3.
 
 - Issue #19936: Added executable bits or shebang lines to Python scripts which