commit:     08f03935b92e8fcacf95c583e389f349f5db67b8
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Apr 29 19:09:00 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Apr 29 20:27:32 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=08f03935

AbstractEbuildProcess: fix deprecated _set_returncode (bug 654276)

Move cleanup code from _set_returncode to _async_waitpid_cb,
since _set_returncode expects an os.waitpid return value which
is inconveniently different from the returncode that is passed to
asyncio.AbstractChildWatcher.add_child_handler callbacks.

Bug: https://bugs.gentoo.org/654276

 pym/_emerge/AbstractEbuildProcess.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/pym/_emerge/AbstractEbuildProcess.py 
b/pym/_emerge/AbstractEbuildProcess.py
index 03c834912..2ed175750 100644
--- a/pym/_emerge/AbstractEbuildProcess.py
+++ b/pym/_emerge/AbstractEbuildProcess.py
@@ -64,7 +64,7 @@ class AbstractEbuildProcess(SpawnProcess):
                        "since PORTAGE_BUILDDIR does not exist: '%s'") % \
                        (self.phase, self.settings['PORTAGE_BUILDDIR'])
                        self._eerror(textwrap.wrap(msg, 72))
-                       self._set_returncode((self.pid, 1 << 8))
+                       self.returncode = 1
                        self._async_wait()
                        return
 
@@ -355,8 +355,12 @@ class AbstractEbuildProcess(SpawnProcess):
                        ["%s received strange poll event: %s\n" % \
                        (self.__class__.__name__, event,)])
 
-       def _set_returncode(self, wait_retval):
-               SpawnProcess._set_returncode(self, wait_retval)
+       def _async_waitpid_cb(self, *args, **kwargs):
+               """
+               Override _async_waitpid_cb to perform cleanup that is
+               not necessarily idempotent.
+               """
+               SpawnProcess._async_waitpid_cb(self, *args, **kwargs)
 
                if self._exit_timeout_id is not None:
                        self.scheduler.source_remove(self._exit_timeout_id)

Reply via email to