From patchwork Tue Jan 11 13:13:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 471451 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0BDDH3b007903 for ; Tue, 11 Jan 2011 13:13:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932088Ab1AKNNQ (ORCPT ); Tue, 11 Jan 2011 08:13:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:62585 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755871Ab1AKNNO (ORCPT ); Tue, 11 Jan 2011 08:13:14 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0BDDDNa018156 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 11 Jan 2011 08:13:13 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0BDDDW0013181; Tue, 11 Jan 2011 08:13:13 -0500 Received: from qu0061.eng.lab.tlv.redhat.com ([10.35.16.61]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p0BDD9nO025030; Tue, 11 Jan 2011 08:13:12 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 02/26] error.py: Unhandled*: don't keep references to unhandled exceptions Date: Tue, 11 Jan 2011 15:13:14 +0200 Message-Id: <1294751618-21631-2-git-send-email-mgoldish@redhat.com> In-Reply-To: <1294751618-21631-1-git-send-email-mgoldish@redhat.com> References: <1294751618-21631-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 11 Jan 2011 13:13:18 +0000 (UTC) diff --git a/client/common_lib/error.py b/client/common_lib/error.py index 76ccc77..0c5641c 100644 --- a/client/common_lib/error.py +++ b/client/common_lib/error.py @@ -181,21 +181,18 @@ class JobError(AutotestError): class UnhandledJobError(JobError): """Indicates an unhandled error in a job.""" def __init__(self, unhandled_exception): - JobError.__init__(self, unhandled_exception) - self.unhandled_exception = unhandled_exception - self.traceback = traceback.format_exc() - - def __str__(self): - if isinstance(self.unhandled_exception, JobError): - return JobError.__str__(self.unhandled_exception) + if isinstance(unhandled_exception, JobError): + JobError.__init__(self, *unhandled_exception.args) + elif isinstance(unhandled_exception, str): + JobError.__init__(self, unhandled_exception) else: msg = "Unhandled %s: %s" - msg %= (self.unhandled_exception.__class__.__name__, - self.unhandled_exception) - if not isinstance(self.unhandled_exception, AutotestError): - msg += _context_message(self.unhandled_exception) - msg += "\n" + self.traceback - return msg + msg %= (unhandled_exception.__class__.__name__, + unhandled_exception) + if not isinstance(unhandled_exception, AutotestError): + msg += _context_message(unhandled_exception) + msg += "\n" + traceback.format_exc() + JobError.__init__(self, msg) class TestBaseException(AutotestError): @@ -229,41 +226,35 @@ class TestWarn(TestBaseException): class UnhandledTestError(TestError): """Indicates an unhandled error in a test.""" def __init__(self, unhandled_exception): - TestError.__init__(self, unhandled_exception) - self.unhandled_exception = unhandled_exception - self.traceback = traceback.format_exc() - - def __str__(self): - if isinstance(self.unhandled_exception, TestError): - return TestError.__str__(self.unhandled_exception) + if isinstance(unhandled_exception, TestError): + TestError.__init__(self, *unhandled_exception.args) + elif isinstance(unhandled_exception, str): + TestError.__init__(self, unhandled_exception) else: msg = "Unhandled %s: %s" - msg %= (self.unhandled_exception.__class__.__name__, - self.unhandled_exception) - if not isinstance(self.unhandled_exception, AutotestError): - msg += _context_message(self.unhandled_exception) - msg += "\n" + self.traceback - return msg + msg %= (unhandled_exception.__class__.__name__, + unhandled_exception) + if not isinstance(unhandled_exception, AutotestError): + msg += _context_message(unhandled_exception) + msg += "\n" + traceback.format_exc() + TestError.__init__(self, msg) class UnhandledTestFail(TestFail): """Indicates an unhandled fail in a test.""" def __init__(self, unhandled_exception): - TestFail.__init__(self, unhandled_exception) - self.unhandled_exception = unhandled_exception - self.traceback = traceback.format_exc() - - def __str__(self): - if isinstance(self.unhandled_exception, TestFail): - return TestFail.__str__(self.unhandled_exception) + if isinstance(unhandled_exception, TestFail): + TestFail.__init__(self, *unhandled_exception.args) + elif isinstance(unhandled_exception, str): + TestFail.__init__(self, unhandled_exception) else: msg = "Unhandled %s: %s" - msg %= (self.unhandled_exception.__class__.__name__, - self.unhandled_exception) - if not isinstance(self.unhandled_exception, AutotestError): - msg += _context_message(self.unhandled_exception) - msg += "\n" + self.traceback - return msg + msg %= (unhandled_exception.__class__.__name__, + unhandled_exception) + if not isinstance(unhandled_exception, AutotestError): + msg += _context_message(unhandled_exception) + msg += "\n" + traceback.format_exc() + TestFail.__init__(self, msg) class CmdError(TestError):