[Python-checkins] cpython (merge 3.4 -> default): merge 3.4 (#21209)

benjamin.peterson python-checkins at python.org
Mon Apr 14 05:52:55 CEST 2014


http://hg.python.org/cpython/rev/d1eba2645b80
changeset:   90241:d1eba2645b80
parent:      90239:3a414c709f1f
parent:      90240:05b3a23b3836
user:        Benjamin Peterson <benjamin at python.org>
date:        Sun Apr 13 23:52:43 2014 -0400
summary:
  merge 3.4 (#21209)

files:
  Lib/test/test_pep380.py |  19 +++++++++++++++++++
  Misc/NEWS               |   3 +++
  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
--- a/Lib/test/test_pep380.py
+++ b/Lib/test/test_pep380.py
@@ -993,6 +993,25 @@
             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
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue #21209: Fix sending tuples to custom generator objects with the yield
+  from syntax.
+
 - Issue #21193: pow(a, b, c) now raises ValueError rather than TypeError when b
   is negative.  Patch by Josh Rosenberg.
 
diff --git a/Python/ceval.c b/Python/ceval.c
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1926,7 +1926,7 @@
                 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) {

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list