]> 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 83682b7dc5398027764a8f635e712e00a2a83fa5..b64469ced6eb4eee9fba1a8d93c317f56ea60f63 100644 (file)
@@ -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")
index 9e49e0694204ebd1a6ba8f935cf7b455de85a651..d5b281e3f472b4725edf426be2485b76d3bef2f7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -168,6 +168,8 @@ Tests
 Tools/Demos
 -----------
 
+- Add support for ``yield from`` to 2to3.
+
 - Add support for the PEP 465 matrix multiplication operator to 2to3.
 
 - Issue #16047: Fix module exception list and __file__ handling in freeze.