diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-12-02 19:00:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-02 19:00:09 (GMT) |
commit | 65d1887170fb278c10a836e9e4319cae4707f524 (patch) | |
tree | 394209c0e5c0f04ebcbca2b94ac1eac432eff0d4 /Lib/test/test_generators.py | |
parent | be6b74c0795b709c7a04e2187a7e32d08f5155f6 (diff) | |
download | cpython-65d1887170fb278c10a836e9e4319cae4707f524.zip cpython-65d1887170fb278c10a836e9e4319cae4707f524.tar.gz cpython-65d1887170fb278c10a836e9e4319cae4707f524.tar.bz2 |
[2.7] bpo-10544: Deprecate "yield" in comprehensions and generator expressions in Py3k mode. (GH-4579) (#4676)
Diffstat (limited to 'Lib/test/test_generators.py')
-rw-r--r-- | Lib/test/test_generators.py | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py index 5e1a3e5..0f7bf19 100644 --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -1524,13 +1524,7 @@ Yield by itself yields None: [None] - -An obscene abuse of a yield expression within a generator expression: - ->>> list((yield 21) for i in range(4)) -[21, None, 21, None, 21, None, 21, None] - -And a more sane, but still weird usage: +Yield is allowed only in the outermost iterable in generator expression: >>> def f(): list(i for i in [(yield 26)]) >>> type(f()) @@ -1571,7 +1565,7 @@ SyntaxError: 'yield' outside function >>> def f(): return lambda x=(yield): 1 Traceback (most recent call last): ... -SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.coroutine[22]>, line 1) +SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.coroutine[21]>, line 1) >>> def f(): x = yield = y Traceback (most recent call last): @@ -1784,7 +1778,7 @@ enclosing function a generator: >>> type(f()) <type 'generator'> ->>> def f(): x=(i for i in (yield) if (yield)) +>>> def f(): x=(i for i in (yield) if i) >>> type(f()) <type 'generator'> |