From 74d2509c99fbcb43e018ead4950b938e41e524e5 Mon Sep 17 00:00:00 2001
From: Zac Medico <zmedico@gentoo.org>
Date: Tue, 20 Nov 2018 02:06:57 -0800
Subject: [PATCH] compat_corouting._GeneratorTask: save throw return (bug
 671472)

According to PEP 342, the generator.throw() method returns a value if
the exception is caught. The return value must be sent to the generator
in order fufill the generator protocol. This is relevant in the
portdbapi.async_xmatch() method, since it catches an exception thrown
with the generator.throw() method.

Bug: https://bugs.gentoo.org/671472
Signed-off-by: Zac Medico <zmedico@gentoo.org>
---
 lib/portage/util/futures/compat_coroutine.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/portage/util/futures/compat_coroutine.py b/lib/portage/util/futures/compat_coroutine.py
index b5ff92fafa..b745fd8450 100644
--- a/lib/portage/util/futures/compat_coroutine.py
+++ b/lib/portage/util/futures/compat_coroutine.py
@@ -106,13 +106,11 @@ def _next(self, previous=None):
 			if previous is None:
 				future = next(self._generator)
 			elif previous.cancelled():
-				self._generator.throw(asyncio.CancelledError())
-				future = next(self._generator)
+				future = self._generator.throw(asyncio.CancelledError())
 			elif previous.exception() is None:
 				future = self._generator.send(previous.result())
 			else:
-				self._generator.throw(previous.exception())
-				future = next(self._generator)
+				future = self._generator.throw(previous.exception())
 
 		except asyncio.CancelledError:
 			self._result.cancel()
