diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-04-14 03:52:01 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-04-14 03:52:01 (GMT) |
commit | f6e50b4a811477206d1c252a531c31029ea93866 (patch) | |
tree | cd2487f0cdeef93232b336fa63c28f0ed42cc2ac | |
parent | 584f5cbf16980f21c58bf7ce7e451e022355fa3d (diff) | |
download | cpython-f6e50b4a811477206d1c252a531c31029ea93866.zip cpython-f6e50b4a811477206d1c252a531c31029ea93866.tar.gz cpython-f6e50b4a811477206d1c252a531c31029ea93866.tar.bz2 |
fix sending tuples to custom generator objects with yield from (closes #21209)
Debugged by Victor.
-rw-r--r-- | Lib/test/test_pep380.py | 19 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Python/ceval.c | 2 |
3 files changed, 23 insertions, 1 deletions
diff --git a/Lib/test/test_pep380.py b/Lib/test/test_pep380.py index 4a43b7d..69194df 100644 --- a/Lib/test/test_pep380.py +++ b/Lib/test/test_pep380.py @@ -993,6 +993,25 @@ class TestPEP380Operation(unittest.TestCase): del inner_gen gc_collect() + def test_send_tuple_with_custom_generator(self): + # See issue #21209. + class MyGen: + def __iter__(self): + return self + def __next__(self): + return 42 + def send(self, what): + nonlocal v + v = what + return None + def outer(): + v = yield from MyGen() + g = outer() + next(g) + v = None + g.send((1, 2, 3, 4)) + self.assertEqual(v, (1, 2, 3, 4)) + def test_main(): from test import support @@ -10,6 +10,9 @@ Release date: TBA Core and Builtins ----------------- +- Issue #21209: Fix sending tuples to custom generator objects with the yield + from syntax. + - Issue #21134: Fix segfault when str is called on an uninitialized UnicodeEncodeError, UnicodeDecodeError, or UnicodeTranslateError object. diff --git a/Python/ceval.c b/Python/ceval.c index 5db88be..1cc3c94 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1902,7 +1902,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) if (v == Py_None) retval = Py_TYPE(reciever)->tp_iternext(reciever); else - retval = _PyObject_CallMethodId(reciever, &PyId_send, "O", v); + retval = _PyObject_CallMethodIdObjArgs(reciever, &PyId_send, v, NULL); } Py_DECREF(v); if (retval == NULL) { |