From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [KVM-AUTOTEST PATCH v2 3/6] [RFC] Introduce exception context strings Date: Wed, 05 Jan 2011 18:22:45 +0200 Message-ID: <4D249AD5.8010109@redhat.com> References: <1294242329-11034-1-git-send-email-mgoldish@redhat.com> <1294242329-11034-3-git-send-email-mgoldish@redhat.com> <4D249855.30607@redhat.com> <20110105162127.GE3361@otherpad.lan.raisama.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Michael Goldish , autotest@test.kernel.org, kvm@vger.kernel.org To: Eduardo Habkost Return-path: Received: from mx1.redhat.com ([209.132.183.28]:2342 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751192Ab1AEQWt (ORCPT ); Wed, 5 Jan 2011 11:22:49 -0500 In-Reply-To: <20110105162127.GE3361@otherpad.lan.raisama.net> Sender: kvm-owner@vger.kernel.org List-ID: On 01/05/2011 06:21 PM, Eduardo Habkost wrote: > On Wed, Jan 05, 2011 at 06:12:05PM +0200, Avi Kivity wrote: > > It would be nice to make the error context a stack, and to use the > > with statement to manage the stack: > > > > > > with error.context("main test"): > > foo() > > with error.context("before reboot"): > > bar() > > > > If foo() throws an exception, the context would be "main test", > > while if bar() throws an exception, the context would be "before > > reboot" in "main test". > > Autotest targets Python 2.4, and Python 2.4 doesn't have the 'with' > statement. > Too bad :( > The error context is already a stack, but without the 'with' statement > you would have to use try/finally explicitly: > > _new_context('foo') > try: > # [...] > finally: > _pop_context() > > By the way, I think we could make _new_context() and _pop_context() part > of the public interface (i.e. remove the "_" from their names). I see > @context_aware as just a helper for a stack interface that could be used > directly if needed. > Yeah. -- error compiling committee.c: too many arguments to function