From: stevenknight Date: Tue, 13 Jul 2004 00:07:19 +0000 (+0000) Subject: Make exception handling conform to Pythonic standards. (Kevin Quick) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c8256bd945fe92e3aee9ad8b554669b87e28f541;p=scons.git Make exception handling conform to Pythonic standards. (Kevin Quick) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1002 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/Errors.py b/src/engine/SCons/Errors.py index 0a576147..283e6819 100644 --- a/src/engine/SCons/Errors.py +++ b/src/engine/SCons/Errors.py @@ -36,25 +36,22 @@ class BuildError(Exception): def __init__(self, node=None, errstr="Unknown error", *args): self.node = node self.errstr = errstr - self.args = args + apply(Exception.__init__, (self,) + args) class InternalError(Exception): - def __init__(self, args=None): - self.args = args + pass class UserError(Exception): - def __init__(self, args=None): - self.args = args + pass class StopError(Exception): - def __init__(self, args=None): - self.args = args + pass class ExplicitExit(Exception): def __init__(self, node=None, status=None, *args): self.node = node self.status = status - self.args = args + apply(Exception.__init__, (self,) + args) class ConfigureDryRunError(UserError): """Raised when a file needs to be updated during a Configure process, @@ -67,4 +64,4 @@ class TaskmasterException(Exception): self.type = type self.value = value self.traceback = traceback - self.args = args + apply(Exception.__init__, (self,) + args) diff --git a/src/engine/SCons/ErrorsTests.py b/src/engine/SCons/ErrorsTests.py index 4771a3f6..bb476108 100644 --- a/src/engine/SCons/ErrorsTests.py +++ b/src/engine/SCons/ErrorsTests.py @@ -42,14 +42,14 @@ class ErrorsTestCase(unittest.TestCase): try: raise SCons.Errors.InternalError, "test internal error" except SCons.Errors.InternalError, e: - assert e.args == "test internal error" + assert e.args == ("test internal error",) def test_UserError(self): """Test the UserError exception.""" try: raise SCons.Errors.UserError, "test user error" except SCons.Errors.UserError, e: - assert e.args == "test user error" + assert e.args == ("test user error",) def test_ExplicitExit(self): """Test the ExplicitExit exception.""" @@ -63,7 +63,7 @@ class ErrorsTestCase(unittest.TestCase): try: raise SCons.Errors.ConfigureDryRunError, "FileName" except SCons.Errors.UserError, e: - assert e.args == "Cannot update configure test (FileName) within a dry-run." + assert e.args == ("Cannot update configure test (FileName) within a dry-run.",) def test_TaskmasterException(self): """Test the TaskmasterException.""" diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 853a9445..2dbb9617 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -332,7 +332,7 @@ def _scons_internal_warning(e): *current call stack* rather than sys.exc_info() to get our stack trace. This is used by the warnings framework to print warnings.""" filename, lineno, routine, dummy = find_deepest_user_frame(traceback.extract_stack()) - sys.stderr.write("\nscons: warning: %s\n" % e) + sys.stderr.write("\nscons: warning: %s\n" % e[0]) sys.stderr.write('File "%s", line %d, in %s\n' % (filename, lineno, routine)) def _scons_internal_error():