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
Core and Builtins
-----------------
+- Issue #15568: Fix the return value of "yield from" when StopIteration is
+ raised by a custom iterator.
+
- Issue #13119: sys.stdout and sys.stderr are now using "\r\n" newline on
Windows, as Python 2.
} else {
_Py_IDENTIFIER(send);
if (u == Py_None)
- retval = PyIter_Next(x);
+ retval = Py_TYPE(x)->tp_iternext(x);
else
retval = _PyObject_CallMethodId(x, &PyId_send, "O", u);
}