1 |
commit: 74d2509c99fbcb43e018ead4950b938e41e524e5 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Nov 20 10:06:57 2018 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Nov 20 10:24:12 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=74d2509c |
7 |
|
8 |
compat_corouting._GeneratorTask: save throw return (bug 671472) |
9 |
|
10 |
According to PEP 342, the generator.throw() method returns a value if |
11 |
the exception is caught. The return value must be sent to the generator |
12 |
in order fufill the generator protocol. This is relevant in the |
13 |
portdbapi.async_xmatch() method, since it catches an exception thrown |
14 |
with the generator.throw() method. |
15 |
|
16 |
Bug: https://bugs.gentoo.org/671472 |
17 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
18 |
|
19 |
lib/portage/util/futures/compat_coroutine.py | 6 ++---- |
20 |
1 file changed, 2 insertions(+), 4 deletions(-) |
21 |
|
22 |
diff --git a/lib/portage/util/futures/compat_coroutine.py b/lib/portage/util/futures/compat_coroutine.py |
23 |
index b5ff92faf..b745fd845 100644 |
24 |
--- a/lib/portage/util/futures/compat_coroutine.py |
25 |
+++ b/lib/portage/util/futures/compat_coroutine.py |
26 |
@@ -106,13 +106,11 @@ class _GeneratorTask(object): |
27 |
if previous is None: |
28 |
future = next(self._generator) |
29 |
elif previous.cancelled(): |
30 |
- self._generator.throw(asyncio.CancelledError()) |
31 |
- future = next(self._generator) |
32 |
+ future = self._generator.throw(asyncio.CancelledError()) |
33 |
elif previous.exception() is None: |
34 |
future = self._generator.send(previous.result()) |
35 |
else: |
36 |
- self._generator.throw(previous.exception()) |
37 |
- future = next(self._generator) |
38 |
+ future = self._generator.throw(previous.exception()) |
39 |
|
40 |
except asyncio.CancelledError: |
41 |
self._result.cancel() |