From: Benjamin Peterson Date: Thu, 10 Apr 2014 04:23:18 +0000 (-0400) Subject: teach 2to3 about 'yield from' X-Git-Tag: v3.4.1rc1~108 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0654be18b387cbd136bfb62d77849111a954b58b;p=python teach 2to3 about 'yield from' --- diff --git a/Lib/lib2to3/Grammar.txt b/Lib/lib2to3/Grammar.txt index bc084e9790..e667bcde69 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 83682b7dc5..b64469ced6 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") diff --git a/Misc/NEWS b/Misc/NEWS index 9e49e06942..d5b281e3f4 100644 --- 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.