]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.6] bpo-33584: Fix several minor bugs in asyncio. (GH-7003) (#7006)
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 20 May 2018 14:33:55 +0000 (17:33 +0300)
committerGitHub <noreply@github.com>
Sun, 20 May 2018 14:33:55 +0000 (17:33 +0300)
* repr() was called for a borrowed link.
* str() was used instead of repr() in formatting one error message.
(cherry picked from commit 6655354afcd116c27486bb5ba1dfa50b369d8d85)

Lib/asyncio/tasks.py
Modules/_asynciomodule.c

index 9fe2a2fabf076a351d41044569e8057e5b4c32b3..a294dfbf5e57cdd0d2a4d8a981bec3357fd44fb0 100644 (file)
@@ -233,7 +233,7 @@ class Task(futures.Future):
                     self._step,
                     RuntimeError(
                         'yield was used instead of yield from for '
-                        'generator in task {!r} with {}'.format(
+                        'generator in task {!r} with {!r}'.format(
                             self, result)))
             else:
                 # Yielding something else is an error.
index f53387115e73aa0d375a1b9854d23816f0bb2e45..1430097f82dacd81d34305ee65f282c764a7a20a 100644 (file)
@@ -2248,19 +2248,19 @@ set_exception:
     }
     if (res == 1) {
         /* `result` is a generator */
-        PyObject *ret;
-        ret = task_set_error_soon(
+        o = task_set_error_soon(
             task, PyExc_RuntimeError,
             "yield was used instead of yield from for "
-            "generator in task %R with %S", task, result);
+            "generator in task %R with %R", task, result);
         Py_DECREF(result);
-        return ret;
+        return o;
     }
 
     /* The `result` is none of the above */
-    Py_DECREF(result);
-    return task_set_error_soon(
+    o = task_set_error_soon(
         task, PyExc_RuntimeError, "Task got bad yield: %R", result);
+    Py_DECREF(result);
+    return o;
 
 self_await:
     o = task_set_error_soon(