diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-08-07 00:53:09 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-08-07 00:53:09 (GMT) |
commit | b37df519c793d40718fda78a9961811fae973f36 (patch) | |
tree | b4a98c5e8e3e070f32a27c36c6f77daeaeb3d141 /Lib/test | |
parent | a0abb4404a839787bc0791c7ea3b261fcd146652 (diff) | |
download | cpython-b37df519c793d40718fda78a9961811fae973f36.zip cpython-b37df519c793d40718fda78a9961811fae973f36.tar.gz cpython-b37df519c793d40718fda78a9961811fae973f36.tar.bz2 |
fix yield from return value on custom iterators (closes #15568)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_pep380.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_pep380.py b/Lib/test/test_pep380.py index 658bcb9..9569e10 100644 --- a/Lib/test/test_pep380.py +++ b/Lib/test/test_pep380.py @@ -940,6 +940,20 @@ class TestPEP380Operation(unittest.TestCase): for stack in spam(eggs(gen())): self.assertTrue('spam' in stack and 'eggs' in stack) + def test_custom_iterator_return(self): + # See issue #15568 + class MyIter: + def __iter__(self): + return self + def __next__(self): + raise StopIteration(42) + def gen(): + nonlocal ret + ret = yield from MyIter() + ret = None + list(gen()) + self.assertEqual(ret, 42) + def test_main(): from test import support |