diff options
author | Steven Knight <knight@baldmt.com> | 2004-07-13 00:07:19 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-07-13 00:07:19 (GMT) |
commit | 321ac083cf44290c309b7021594c3941bfa3f82f (patch) | |
tree | 6252e83c8b56d8fc9a8d28a2472fd805f6242aaa /src | |
parent | bb10501c96110a8f9a9068344c7f89e79e97fef2 (diff) | |
download | SCons-321ac083cf44290c309b7021594c3941bfa3f82f.zip SCons-321ac083cf44290c309b7021594c3941bfa3f82f.tar.gz SCons-321ac083cf44290c309b7021594c3941bfa3f82f.tar.bz2 |
Make exception handling conform to Pythonic standards. (Kevin Quick)
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/SCons/Errors.py | 15 | ||||
-rw-r--r-- | src/engine/SCons/ErrorsTests.py | 6 | ||||
-rw-r--r-- | src/engine/SCons/Script/__init__.py | 2 |
3 files changed, 10 insertions, 13 deletions
diff --git a/src/engine/SCons/Errors.py b/src/engine/SCons/Errors.py index 0a57614..283e681 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 4771a3f..bb47610 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 853a944..2dbb961 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(): |