cpython: d1eba2645b80 (original) (raw)
Mercurial > cpython
changeset 90241:d1eba2645b80
merge 3.4 (#21209) [#21209]
Benjamin Peterson benjamin@python.org | |
---|---|
date | Sun, 13 Apr 2014 23:52:43 -0400 |
parents | 3a414c709f1f(current diff)05b3a23b3836(diff) |
children | 6107a727c60a |
files | Misc/NEWS Python/ceval.c |
diffstat | 3 files changed, 23 insertions(+), 1 deletions(-)[+] [-] Lib/test/test_pep380.py 19 Misc/NEWS 3 Python/ceval.c 2 |
line wrap: on
line diff
--- a/Lib/test/test_pep380.py +++ b/Lib/test/test_pep380.py @@ -993,6 +993,25 @@ class TestPEP380Operation(unittest.TestC del inner_gen gc_collect()
- def test_send_tuple_with_custom_generator(self):
# See issue #21209.[](#l1.8)
class MyGen:[](#l1.9)
def __iter__(self):[](#l1.10)
return self[](#l1.11)
def __next__(self):[](#l1.12)
return 42[](#l1.13)
def send(self, what):[](#l1.14)
nonlocal v[](#l1.15)
v = what[](#l1.16)
return None[](#l1.17)
def outer():[](#l1.18)
v = yield from MyGen()[](#l1.19)
g = outer()[](#l1.20)
next(g)[](#l1.21)
v = None[](#l1.22)
g.send((1, 2, 3, 4))[](#l1.23)
self.assertEqual(v, (1, 2, 3, 4))[](#l1.24)
+ def test_main(): from test import support
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Release date: TBA Core and Builtins ----------------- +- Issue #21209: Fix sending tuples to custom generator objects with the yield
- Issue #21193: pow(a, b, c) now raises ValueError rather than TypeError when b is negative. Patch by Josh Rosenberg.
--- a/Python/ceval.c +++ b/Python/ceval.c @@ -1926,7 +1926,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int if (v == Py_None) retval = Py_TYPE(reciever)->tp_iternext(reciever); else
retval = _PyObject_CallMethodId(reciever, &PyId_send, "O", v);[](#l3.7)
retval = _PyObject_CallMethodIdObjArgs(reciever, &PyId_send, v, NULL);[](#l3.8) }[](#l3.9) Py_DECREF(v);[](#l3.10) if (retval == NULL) {[](#l3.11)