From: Zac Medico Date: Mon, 8 Oct 2012 14:54:14 +0000 (-0700) Subject: spawn: use finally block for failure os._exit() X-Git-Tag: v2.2.0_alpha136~8 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=84ce763b5d397dc836b7132c0961d8f2b1a2d1f1;p=portage.git spawn: use finally block for failure os._exit() Also, use writemsg for unicode safety. --- diff --git a/pym/portage/process.py b/pym/portage/process.py index 32e60ac50..a3461f474 100644 --- a/pym/portage/process.py +++ b/pym/portage/process.py @@ -15,7 +15,7 @@ from portage import _encodings from portage import _unicode_encode import portage portage.proxy.lazyimport.lazyimport(globals(), - 'portage.util:dump_traceback', + 'portage.util:dump_traceback,writemsg', ) from portage.const import BASH_BINARY, SANDBOX_BINARY, FAKEROOT_BINARY @@ -268,9 +268,12 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False, # We need to catch _any_ exception so that it doesn't # propagate out of this function and cause exiting # with anything other than os._exit() - sys.stderr.write("%s:\n %s\n" % (e, " ".join(mycommand))) + writemsg("%s:\n %s\n" % (e, " ".join(mycommand)), noiselevel=-1) traceback.print_exc() sys.stderr.flush() + finally: + # Call os._exit() from finally block, in order to suppress any + # finally blocks from earlier in the call stack. See bug #345289. os._exit(1) if not isinstance(pid, int):