summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons
diff options
context:
space:
mode:
authorGreg Noel <GregNoel@tigris.org>2010-04-15 00:02:59 (GMT)
committerGreg Noel <GregNoel@tigris.org>2010-04-15 00:02:59 (GMT)
commit9931fe6c59d330d0dbeea1c51456e3a9f94377d8 (patch)
tree0e17c9808475e40bfad54db43529ad01d411e6c2 /src/engine/SCons
parent12ec17eedc70ee82421b27ff7dd84e947d4e6953 (diff)
downloadSCons-9931fe6c59d330d0dbeea1c51456e3a9f94377d8.zip
SCons-9931fe6c59d330d0dbeea1c51456e3a9f94377d8.tar.gz
SCons-9931fe6c59d330d0dbeea1c51456e3a9f94377d8.tar.bz2
http://scons.tigris.org/issues/show_bug.cgi?id=2345
Apply the first part of the 'raise' fixer (the three-argument cases are not converted and will need to wait until native support of with_traceback() is available).
Diffstat (limited to 'src/engine/SCons')
-rw-r--r--src/engine/SCons/Action.py6
-rw-r--r--src/engine/SCons/ActionTests.py4
-rw-r--r--src/engine/SCons/Builder.py22
-rw-r--r--src/engine/SCons/BuilderTests.py2
-rw-r--r--src/engine/SCons/CacheDir.py2
-rw-r--r--src/engine/SCons/Defaults.py2
-rw-r--r--src/engine/SCons/Environment.py20
-rw-r--r--src/engine/SCons/EnvironmentTests.py2
-rw-r--r--src/engine/SCons/ErrorsTests.py6
-rw-r--r--src/engine/SCons/Executor.py4
-rw-r--r--src/engine/SCons/ExecutorTests.py6
-rw-r--r--src/engine/SCons/JobTests.py6
-rw-r--r--src/engine/SCons/Memoize.py2
-rw-r--r--src/engine/SCons/Node/FS.py24
-rw-r--r--src/engine/SCons/Node/FSTests.py8
-rw-r--r--src/engine/SCons/Node/NodeTests.py10
-rw-r--r--src/engine/SCons/Node/__init__.py4
-rw-r--r--src/engine/SCons/Platform/__init__.py2
-rw-r--r--src/engine/SCons/SConf.py14
-rw-r--r--src/engine/SCons/SConfTests.py2
-rw-r--r--src/engine/SCons/SConsignTests.py4
-rw-r--r--src/engine/SCons/Scanner/FortranTests.py2
-rw-r--r--src/engine/SCons/Scanner/IDLTests.py2
-rw-r--r--src/engine/SCons/Script/Main.py6
-rw-r--r--src/engine/SCons/Script/SConsOptions.py20
-rw-r--r--src/engine/SCons/Script/SConscript.py21
-rw-r--r--src/engine/SCons/Subst.py6
-rw-r--r--src/engine/SCons/SubstTests.py12
-rw-r--r--src/engine/SCons/Taskmaster.py2
-rw-r--r--src/engine/SCons/TaskmasterTests.py14
-rw-r--r--src/engine/SCons/Tool/JavaCommon.py2
-rw-r--r--src/engine/SCons/Tool/MSCommon/sdk.py4
-rw-r--r--src/engine/SCons/Tool/MSCommon/vc.py4
-rw-r--r--src/engine/SCons/Tool/MSCommon/vs.py4
-rw-r--r--src/engine/SCons/Tool/PharLapCommon.py6
-rw-r--r--src/engine/SCons/Tool/__init__.py8
-rw-r--r--src/engine/SCons/Tool/install.py6
-rw-r--r--src/engine/SCons/Tool/intelc.py24
-rw-r--r--src/engine/SCons/Tool/mingw.py2
-rw-r--r--src/engine/SCons/Tool/mslink.py6
-rw-r--r--src/engine/SCons/Tool/msvc.py4
-rw-r--r--src/engine/SCons/Tool/msvs.py70
-rw-r--r--src/engine/SCons/Tool/mwld.py2
-rw-r--r--src/engine/SCons/Tool/packaging/__init__.py6
-rw-r--r--src/engine/SCons/Util.py2
-rw-r--r--src/engine/SCons/UtilTests.py2
-rw-r--r--src/engine/SCons/Variables/PathVariableTests.py18
-rw-r--r--src/engine/SCons/Variables/__init__.py6
-rw-r--r--src/engine/SCons/compat/__init__.py2
-rw-r--r--src/engine/SCons/compat/_scons_hashlib.py2
-rw-r--r--src/engine/SCons/compat/_scons_optparse.py20
-rw-r--r--src/engine/SCons/compat/_scons_sets.py8
-rw-r--r--src/engine/SCons/compat/_scons_shlex.py4
-rw-r--r--src/engine/SCons/cpp.py2
-rw-r--r--src/engine/SCons/dblite.py14
55 files changed, 220 insertions, 245 deletions
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py
index ff67b49..6b04612 100644
--- a/src/engine/SCons/Action.py
+++ b/src/engine/SCons/Action.py
@@ -302,7 +302,7 @@ def _actionAppend(act1, act2):
a1 = Action(act1)
a2 = Action(act2)
if a1 is None or a2 is None:
- raise TypeError, "Cannot append %s to %s" % (type(act1), type(act2))
+ raise TypeError("Cannot append %s to %s" % (type(act1), type(act2)))
if isinstance(a1, ListAction):
if isinstance(a2, ListAction):
return ListAction(a1.list + a2.list)
@@ -691,8 +691,8 @@ class CommandAction(_ActionAction):
_ActionAction.__init__(self, **kw)
if is_List(cmd):
if list(filter(is_List, cmd)):
- raise TypeError, "CommandAction should be given only " \
- "a single command"
+ raise TypeError("CommandAction should be given only " \
+ "a single command")
self.cmd_list = cmd
def __str__(self):
diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py
index 4cb5a0a..4ffbdec 100644
--- a/src/engine/SCons/ActionTests.py
+++ b/src/engine/SCons/ActionTests.py
@@ -275,7 +275,7 @@ def test_positional_args(pos_callback, cmd, **kw):
m = 'Invalid command display variable'
assert s.find(m) != -1, 'Unexpected string: %s' % s
else:
- raise Exception, "did not catch expected UserError"
+ raise Exception("did not catch expected UserError")
return act
@@ -494,7 +494,7 @@ class _ActionActionTestCase(unittest.TestCase):
m = 'Cannot have both strfunction and cmdstr args to Action()'
assert s.find(m) != -1, 'Unexpected string: %s' % s
else:
- raise Exception, "did not catch expected UserError"
+ raise Exception("did not catch expected UserError")
def test___cmp__(self):
"""Test Action comparison
diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py
index 4cce92f..bbf503c 100644
--- a/src/engine/SCons/Builder.py
+++ b/src/engine/SCons/Builder.py
@@ -244,7 +244,7 @@ def Builder(**kw):
composite = None
if 'generator' in kw:
if 'action' in kw:
- raise UserError, "You must not specify both an action and a generator."
+ raise UserError("You must not specify both an action and a generator.")
kw['action'] = SCons.Action.CommandGeneratorAction(kw['generator'], {})
del kw['generator']
elif 'action' in kw:
@@ -267,7 +267,7 @@ def Builder(**kw):
# a callable to use as the actual emitter.
var = SCons.Util.get_environment_var(emitter)
if not var:
- raise UserError, "Supplied emitter '%s' does not appear to refer to an Environment variable" % emitter
+ raise UserError("Supplied emitter '%s' does not appear to refer to an Environment variable" % emitter)
kw['emitter'] = EmitterProxy(var)
elif SCons.Util.is_Dict(emitter):
kw['emitter'] = DictEmitter(emitter)
@@ -291,7 +291,7 @@ def _node_errors(builder, env, tlist, slist):
# were specified.
for t in tlist:
if t.side_effect:
- raise UserError, "Multiple ways to build the same target were specified for: %s" % t
+ raise UserError("Multiple ways to build the same target were specified for: %s" % t)
if t.has_explicit_builder():
if not t.env is None and not t.env is env:
action = t.builder.action
@@ -303,22 +303,22 @@ def _node_errors(builder, env, tlist, slist):
SCons.Warnings.warn(SCons.Warnings.DuplicateEnvironmentWarning, msg)
else:
msg = "Two environments with different actions were specified for the same target: %s" % t
- raise UserError, msg
+ raise UserError(msg)
if builder.multi:
if t.builder != builder:
msg = "Two different builders (%s and %s) were specified for the same target: %s" % (t.builder.get_name(env), builder.get_name(env), t)
- raise UserError, msg
+ raise UserError(msg)
# TODO(batch): list constructed each time!
if t.get_executor().get_all_targets() != tlist:
msg = "Two different target lists have a target in common: %s (from %s and from %s)" % (t, list(map(str, t.get_executor().get_all_targets())), list(map(str, tlist)))
- raise UserError, msg
+ raise UserError(msg)
elif t.sources != slist:
msg = "Multiple ways to build the same target were specified for: %s (from %s and from %s)" % (t, list(map(str, t.sources)), list(map(str, slist)))
- raise UserError, msg
+ raise UserError(msg)
if builder.single_source:
if len(slist) > 1:
- raise UserError, "More than one source given for single-source builder: targets=%s sources=%s" % (list(map(str,tlist)), list(map(str,slist)))
+ raise UserError("More than one source given for single-source builder: targets=%s sources=%s" % (list(map(str,tlist)), list(map(str,slist))))
class EmitterProxy:
"""This is a callable class that can act as a
@@ -429,7 +429,7 @@ class BuilderBase:
self.src_builder = src_builder
def __nonzero__(self):
- raise InternalError, "Do not test for the Node.builder attribute directly; use Node.has_builder() instead"
+ raise InternalError("Do not test for the Node.builder attribute directly; use Node.has_builder() instead")
def get_name(self, env):
"""Attempts to get the name of the Builder.
@@ -575,8 +575,8 @@ class BuilderBase:
if executor is None:
if not self.action:
fmt = "Builder %s must have an action to build %s."
- raise UserError, fmt % (self.get_name(env or self.env),
- list(map(str,tlist)))
+ raise UserError(fmt % (self.get_name(env or self.env),
+ list(map(str,tlist))))
key = self.action.batch_key(env or self.env, tlist, slist)
if key:
try:
diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py
index 38eb0ca..50cf778 100644
--- a/src/engine/SCons/BuilderTests.py
+++ b/src/engine/SCons/BuilderTests.py
@@ -344,7 +344,7 @@ class BuilderTestCase(unittest.TestCase):
except SCons.Errors.UserError, e:
pass
else:
- raise "Did not catch expected UserError."
+ raise Exception("Did not catch expected UserError.")
builder = SCons.Builder.Builder(action="foo")
target = builder(env, None, source='n22', srcdir='src_dir')[0]
diff --git a/src/engine/SCons/CacheDir.py b/src/engine/SCons/CacheDir.py
index d585888..3ccfe7f 100644
--- a/src/engine/SCons/CacheDir.py
+++ b/src/engine/SCons/CacheDir.py
@@ -100,7 +100,7 @@ def CachePushFunc(target, source, env):
# has beaten us creating the directory.
if not fs.isdir(cachedir):
msg = errfmt % (str(target), cachefile)
- raise SCons.Errors.EnvironmentError, msg
+ raise SCons.Errors.EnvironmentError(msg)
try:
if fs.islink(t.path):
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py
index f532354..cc2e0a0 100644
--- a/src/engine/SCons/Defaults.py
+++ b/src/engine/SCons/Defaults.py
@@ -118,7 +118,7 @@ def SharedFlagChecker(source, target, env):
except AttributeError:
shared = None
if not shared:
- raise SCons.Errors.UserError, "Source file: %s is static and is not compatible with shared target: %s" % (src, target[0])
+ raise SCons.Errors.UserError("Source file: %s is static and is not compatible with shared target: %s" % (src, target[0]))
SharedCheck = SCons.Action.Action(SharedFlagChecker, None)
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index 5449669..cd637bb 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -271,7 +271,7 @@ class BuilderWrapper(MethodWrapper):
elif name == 'builder':
return self.method
else:
- raise AttributeError, name
+ raise AttributeError(name)
def __setattr__(self, name, value):
if name == 'env':
@@ -432,7 +432,7 @@ class SubstitutionEnvironment:
# efficient than calling another function or a method.
if key not in self._dict \
and not _is_valid_var.match(key):
- raise SCons.Errors.UserError, "Illegal construction variable `%s'" % key
+ raise SCons.Errors.UserError("Illegal construction variable `%s'" % key)
self._dict[key] = value
def get(self, key, default=None):
@@ -1382,7 +1382,7 @@ class Base(SubstitutionEnvironment):
copy_function = self._copy2_from_cache
if function in ('MD5', 'content'):
if not SCons.Util.md5:
- raise UserError, "MD5 signatures are not available in this version of Python."
+ raise UserError("MD5 signatures are not available in this version of Python.")
function = self._changed_content
elif function == 'MD5-timestamp':
function = self._changed_timestamp_then_content
@@ -1392,7 +1392,7 @@ class Base(SubstitutionEnvironment):
elif function == 'timestamp-match':
function = self._changed_timestamp_match
elif not callable(function):
- raise UserError, "Unknown Decider value %s" % repr(function)
+ raise UserError("Unknown Decider value %s" % repr(function))
# We don't use AddMethod because we don't want to turn the
# function, which only expects three arguments, into a bound
@@ -2049,7 +2049,7 @@ class Base(SubstitutionEnvironment):
for side_effect in side_effects:
if side_effect.multiple_side_effect_has_builder():
- raise SCons.Errors.UserError, "Multiple ways to build the same target were specified for: %s" % str(side_effect)
+ raise SCons.Errors.UserError("Multiple ways to build the same target were specified for: %s" % str(side_effect))
side_effect.add_source(targets)
side_effect.side_effect = 1
self.Precious(side_effect)
@@ -2075,12 +2075,12 @@ class Base(SubstitutionEnvironment):
self.src_sig_type = type
if type == 'MD5':
if not SCons.Util.md5:
- raise UserError, "MD5 signatures are not available in this version of Python."
+ raise UserError("MD5 signatures are not available in this version of Python.")
self.decide_source = self._changed_content
elif type == 'timestamp':
self.decide_source = self._changed_timestamp_match
else:
- raise UserError, "Unknown source signature type '%s'" % type
+ raise UserError("Unknown source signature type '%s'" % type)
def Split(self, arg):
"""This function converts a string or list into a list of strings
@@ -2111,7 +2111,7 @@ class Base(SubstitutionEnvironment):
self.tgt_sig_type = type
if type in ('MD5', 'content'):
if not SCons.Util.md5:
- raise UserError, "MD5 signatures are not available in this version of Python."
+ raise UserError("MD5 signatures are not available in this version of Python.")
self.decide_target = self._changed_content
elif type == 'timestamp':
self.decide_target = self._changed_timestamp_match
@@ -2120,7 +2120,7 @@ class Base(SubstitutionEnvironment):
elif type == 'source':
self.decide_target = self._changed_source
else:
- raise UserError, "Unknown target signature type '%s'"%type
+ raise UserError("Unknown target signature type '%s'"%type)
def Value(self, value, built_value=None):
"""
@@ -2209,7 +2209,7 @@ class OverrideEnvironment(Base):
return self.__dict__['__subject'].__getitem__(key)
def __setitem__(self, key, value):
if not is_valid_construction_var(key):
- raise SCons.Errors.UserError, "Illegal construction variable `%s'" % key
+ raise SCons.Errors.UserError("Illegal construction variable `%s'" % key)
self.__dict__['overrides'][key] = value
def __delitem__(self, key):
try:
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 0719853..9f0e167 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -1610,7 +1610,7 @@ def exists(env):
def __str__(self):
return self.name
def __cmp__(self, other):
- raise "should not compare"
+ raise Exception("should not compare")
ccc = C('ccc')
diff --git a/src/engine/SCons/ErrorsTests.py b/src/engine/SCons/ErrorsTests.py
index 1eee6e1..9c8b925 100644
--- a/src/engine/SCons/ErrorsTests.py
+++ b/src/engine/SCons/ErrorsTests.py
@@ -79,21 +79,21 @@ class ErrorsTestCase(unittest.TestCase):
def test_InternalError(self):
"""Test the InternalError exception."""
try:
- raise SCons.Errors.InternalError, "test internal error"
+ raise SCons.Errors.InternalError("test internal error")
except SCons.Errors.InternalError, e:
assert e.args == ("test internal error",)
def test_UserError(self):
"""Test the UserError exception."""
try:
- raise SCons.Errors.UserError, "test user error"
+ raise SCons.Errors.UserError("test user error")
except SCons.Errors.UserError, e:
assert e.args == ("test user error",)
def test_ExplicitExit(self):
"""Test the ExplicitExit exception."""
try:
- raise SCons.Errors.ExplicitExit, "node"
+ raise SCons.Errors.ExplicitExit("node")
except SCons.Errors.ExplicitExit, e:
assert e.node == "node"
diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py
index 8f9b917..feedf57 100644
--- a/src/engine/SCons/Executor.py
+++ b/src/engine/SCons/Executor.py
@@ -226,7 +226,7 @@ class Executor:
if not SCons.Util.is_List(action):
if not action:
import SCons.Errors
- raise SCons.Errors.UserError, "Executor must have an action."
+ raise SCons.Errors.UserError("Executor must have an action.")
action = [action]
self.action_list = action
@@ -394,7 +394,7 @@ class Executor:
for s in self.get_all_sources():
if s.missing():
msg = "Source `%s' not found, needed by target `%s'."
- raise SCons.Errors.StopError, msg % (s, self.batches[0].targets[0])
+ raise SCons.Errors.StopError(msg % (s, self.batches[0].targets[0]))
def add_pre_action(self, action):
self.pre_actions.append(action)
diff --git a/src/engine/SCons/ExecutorTests.py b/src/engine/SCons/ExecutorTests.py
index aaafa07..8e06742 100644
--- a/src/engine/SCons/ExecutorTests.py
+++ b/src/engine/SCons/ExecutorTests.py
@@ -119,7 +119,7 @@ class ExecutorTestCase(unittest.TestCase):
except SCons.Errors.UserError:
pass
else:
- raise "Did not catch expected UserError"
+ raise Exception("Did not catch expected UserError")
def test__action_list(self):
"""Test the {get,set}_action_list() methods"""
@@ -242,7 +242,7 @@ class ExecutorTestCase(unittest.TestCase):
except SCons.Errors.BuildError:
pass
else:
- raise Exception, "Did not catch expected BuildError"
+ raise Exception("Did not catch expected BuildError")
assert result == ['pre_err'], result
del result[:]
@@ -310,7 +310,7 @@ class ExecutorTestCase(unittest.TestCase):
except SCons.Errors.StopError, e:
assert str(e) == "Source `s2' not found, needed by target `t1'.", e
else:
- raise AssertionError, "did not catch expected StopError: %s" % r
+ raise AssertionError("did not catch expected StopError: %s" % r)
def test_add_pre_action(self):
"""Test adding pre-actions to an Executor"""
diff --git a/src/engine/SCons/JobTests.py b/src/engine/SCons/JobTests.py
index 85708ad..6e39d4b 100644
--- a/src/engine/SCons/JobTests.py
+++ b/src/engine/SCons/JobTests.py
@@ -398,7 +398,7 @@ class badnode (goodnode):
goodnode.__init__(self)
self.expect_to_be = SCons.Node.failed
def build(self, **kw):
- raise Exception, 'badnode exception'
+ raise Exception('badnode exception')
class slowbadnode (badnode):
def build(self, **kw):
@@ -407,11 +407,11 @@ class slowbadnode (badnode):
# it is faster than slowgoodnode then these could complete
# while the scheduler is sleeping.
time.sleep(0.05)
- raise Exception, 'slowbadnode exception'
+ raise Exception('slowbadnode exception')
class badpreparenode (badnode):
def prepare(self):
- raise Exception, 'badpreparenode exception'
+ raise Exception('badpreparenode exception')
class _SConsTaskTest(unittest.TestCase):
diff --git a/src/engine/SCons/Memoize.py b/src/engine/SCons/Memoize.py
index 4566d31..30e7d9f 100644
--- a/src/engine/SCons/Memoize.py
+++ b/src/engine/SCons/Memoize.py
@@ -257,7 +257,7 @@ if not use_metaclass:
def EnableMemoization():
import SCons.Warnings
msg = 'memoization is not supported in this version of Python (%s)'
- raise SCons.Warnings.NoMetaclassSupportWarning, msg % reason
+ raise SCons.Warnings.NoMetaclassSupportWarning(msg % reason)
else:
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index acba76e..6dd5b0b 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -255,7 +255,7 @@ def set_duplicate(duplicate):
}
if not duplicate in Valid_Duplicates:
- raise SCons.Errors.InternalError, ("The argument of set_duplicate "
+ raise SCons.Errors.InternalError("The argument of set_duplicate "
"should be in Valid_Duplicates")
global Link_Funcs
Link_Funcs = []
@@ -406,7 +406,7 @@ def do_diskcheck_match(node, predicate, errorfmt):
except (AttributeError, KeyError):
pass
if result:
- raise TypeError, errorfmt % node.abspath
+ raise TypeError(errorfmt % node.abspath)
def ignore_diskcheck_match(node, predicate, errorfmt):
pass
@@ -619,8 +619,8 @@ class Base(SCons.Node.Node):
"""
if isinstance(self, klass) or klass is Entry:
return
- raise TypeError, "Tried to lookup %s '%s' as a %s." %\
- (self.__class__.__name__, self.path, klass.__name__)
+ raise TypeError("Tried to lookup %s '%s' as a %s." %\
+ (self.__class__.__name__, self.path, klass.__name__))
def get_dir(self):
return self.dir
@@ -910,7 +910,7 @@ class Entry(Base):
self._morph()
elif must_exist:
msg = "No such file or directory: '%s'" % self.abspath
- raise SCons.Errors.UserError, msg
+ raise SCons.Errors.UserError(msg)
else:
self.__class__ = File
self._morph()
@@ -989,7 +989,7 @@ class Entry(Base):
def rel_path(self, other):
d = self.disambiguate()
if d.__class__ is Entry:
- raise "rel_path() could not disambiguate File/Dir"
+ raise Exception("rel_path() could not disambiguate File/Dir")
return d.rel_path(other)
def new_ninfo(self):
@@ -1293,11 +1293,11 @@ class FS(LocalFS):
if not isinstance(variant_dir, SCons.Node.Node):
variant_dir = self.Dir(variant_dir)
if src_dir.is_under(variant_dir):
- raise SCons.Errors.UserError, "Source directory cannot be under variant directory."
+ raise SCons.Errors.UserError("Source directory cannot be under variant directory.")
if variant_dir.srcdir:
if variant_dir.srcdir == src_dir:
return # We already did this.
- raise SCons.Errors.UserError, "'%s' already has a source directory: '%s'."%(variant_dir, variant_dir.srcdir)
+ raise SCons.Errors.UserError("'%s' already has a source directory: '%s'."%(variant_dir, variant_dir.srcdir))
variant_dir.link(src_dir, duplicate)
def Repository(self, *dirs):
@@ -1640,7 +1640,7 @@ class Dir(Base):
if p is None:
# Don't use while: - else: for this condition because
# if so, then parent is None and has no .path attribute.
- raise SCons.Errors.StopError, parent.path
+ raise SCons.Errors.StopError(parent.path)
parent = p
listDirs.reverse()
for dirnode in listDirs:
@@ -2104,7 +2104,7 @@ class RootDir(Dir):
except KeyError:
if not create:
msg = "No such file or directory: '%s' in '%s' (and create is False)" % (p, str(self))
- raise SCons.Errors.UserError, msg
+ raise SCons.Errors.UserError(msg)
# There is no Node for this path name, and we're allowed
# to create it.
dir_name, file_name = os.path.split(p)
@@ -2734,7 +2734,7 @@ class File(Base):
self._createDir()
except SCons.Errors.StopError, drive:
desc = "No drive `%s' for target `%s'." % (drive, self)
- raise SCons.Errors.StopError, desc
+ raise SCons.Errors.StopError(desc)
#
#
@@ -2753,7 +2753,7 @@ class File(Base):
e = Link(self, src, None)
if isinstance(e, SCons.Errors.BuildError):
desc = "Cannot duplicate `%s' in `%s': %s." % (src.path, self.dir.path, e.errstr)
- raise SCons.Errors.StopError, desc
+ raise SCons.Errors.StopError(desc)
self.linked = 1
# The Link() action may or may not have actually
# created the file, depending on whether the -n
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index 01ceb51..8ced548 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -358,7 +358,7 @@ class VariantDirTestCase(unittest.TestCase):
save_Link = SCons.Node.FS.Link
def Link_IOError(target, source, env):
- raise IOError, (17, "Link_IOError")
+ raise IOError(17, "Link_IOError")
SCons.Node.FS.Link = SCons.Action.Action(Link_IOError, None)
test.write(['work', 'src', 'IOError'], "work/src/IOError\n")
@@ -892,7 +892,7 @@ class FSTestCase(_tempdirTestCase):
except TypeError:
pass
else:
- raise Exception, "did not catch expected TypeError"
+ raise Exception("did not catch expected TypeError")
assert x1.Entry(x4) == x4
try:
@@ -900,7 +900,7 @@ class FSTestCase(_tempdirTestCase):
except TypeError:
pass
else:
- raise Exception, "did not catch expected TypeError"
+ raise Exception("did not catch expected TypeError")
x6 = x1.File(x6)
assert isinstance(x6, SCons.Node.FS.File)
@@ -1207,7 +1207,7 @@ class FSTestCase(_tempdirTestCase):
except SCons.Errors.UserError:
pass
else:
- raise Exception, "did not catch expected UserError"
+ raise Exception("did not catch expected UserError")
nonexistent(fs.Entry, 'nonexistent')
nonexistent(fs.Entry, 'nonexistent/foo')
diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py
index 5f1b4b0..6de6d38 100644
--- a/src/engine/SCons/Node/NodeTests.py
+++ b/src/engine/SCons/Node/NodeTests.py
@@ -54,7 +54,7 @@ def _actionAppend(a1, a2):
elif isinstance(curr_a, list):
all.extend(curr_a)
else:
- raise 'Cannot Combine Actions'
+ raise Exception('Cannot Combine Actions')
return MyListAction(all)
class MyActionBase:
@@ -178,7 +178,7 @@ class ExceptBuilder:
class ExceptBuilder2:
def execute(self, target, source, env):
- raise "foo"
+ raise Exception("foo")
class Scanner:
called = None
@@ -787,7 +787,7 @@ class NodeTestCase(unittest.TestCase):
except:
pass
else:
- raise "did not catch expected exception"
+ raise Exception("did not catch expected exception")
assert node.depends == [zero, one, two, three, four]
@@ -819,7 +819,7 @@ class NodeTestCase(unittest.TestCase):
except:
pass
else:
- raise "did not catch expected exception"
+ raise Exception("did not catch expected exception")
assert node.sources == [zero, one, two, three, four], node.sources
def test_add_ignore(self):
@@ -850,7 +850,7 @@ class NodeTestCase(unittest.TestCase):
except:
pass
else:
- raise "did not catch expected exception"
+ raise Exception("did not catch expected exception")
assert node.ignore == [zero, one, two, three, four]
def test_get_found_includes(self):
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py
index 472f99f..d635933 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -350,12 +350,12 @@ class Node:
for d in self.depends:
if d.missing():
msg = "Explicit dependency `%s' not found, needed by target `%s'."
- raise SCons.Errors.StopError, msg % (d, self)
+ raise SCons.Errors.StopError(msg % (d, self))
if self.implicit is not None:
for i in self.implicit:
if i.missing():
msg = "Implicit dependency `%s' not found, needed by target `%s'."
- raise SCons.Errors.StopError, msg % (i, self)
+ raise SCons.Errors.StopError(msg % (i, self))
self.binfo = self.get_binfo()
def build(self, **kw):
diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py
index 2ae1e97..244d090 100644
--- a/src/engine/SCons/Platform/__init__.py
+++ b/src/engine/SCons/Platform/__init__.py
@@ -111,7 +111,7 @@ def platform_module(name = platform_default()):
importer = zipimport.zipimporter( sys.modules['SCons.Platform'].__path__[0] )
mod = importer.load_module(full_name)
except ImportError:
- raise SCons.Errors.UserError, "No platform named '%s'" % name
+ raise SCons.Errors.UserError("No platform named '%s'" % name)
setattr(SCons.Platform, name, mod)
return sys.modules[full_name]
diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py
index ac019ad..387312b 100644
--- a/src/engine/SCons/SConf.py
+++ b/src/engine/SCons/SConf.py
@@ -79,7 +79,7 @@ def SetCacheMode(mode):
elif mode == "cache":
cache_mode = CACHE
else:
- raise ValueError, "SCons.SConf.SetCacheMode: Unknown mode " + mode
+ raise ValueError("SCons.SConf.SetCacheMode: Unknown mode " + mode)
progress_display = SCons.Util.display # will be overwritten by SCons.Script
def SetProgressDisplay(display):
@@ -397,8 +397,7 @@ class SConfBase:
SConfFS = SCons.Node.FS.default_fs or \
SCons.Node.FS.FS(env.fs.pathTop)
if sconf_global is not None:
- raise (SCons.Errors.UserError,
- "Only one SConf object may be active at one time")
+ raise SCons.Errors.UserError
self.env = env
if log_file is not None:
log_file = SConfFS.File(env.subst(log_file))
@@ -639,8 +638,7 @@ class SConfBase:
self.sconf = sconf
def __call__(self, *args, **kw):
if not self.sconf.active:
- raise (SCons.Errors.UserError,
- "Test called after sconf.Finish()")
+ raise SCons.Errors.UserError
context = CheckContext(self.sconf)
ret = self.test(context, *args, **kw)
if self.sconf.config_h is not None:
@@ -721,7 +719,7 @@ class SConfBase:
global sconf_global, _ac_config_hs
if not self.active:
- raise SCons.Errors.UserError, "Finish may be called only once!"
+ raise SCons.Errors.UserError("Finish may be called only once!")
if self.logstream is not None and not dryrun:
self.logstream.write("\n")
self.logstream.close()
@@ -793,7 +791,7 @@ class CheckContext:
elif isinstance(res, str):
text = res
else:
- raise TypeError, "Expected string, int or bool, got " + str(type(res))
+ raise TypeError("Expected string, int or bool, got " + str(type(res)))
if self.did_show_result == 0:
# Didn't show result yet, do it now.
@@ -821,7 +819,7 @@ class CheckContext:
elif( attr == 'lastTarget' ):
return self.sconf.lastTarget
else:
- raise AttributeError, "CheckContext instance has no attribute '%s'" % attr
+ raise AttributeError("CheckContext instance has no attribute '%s'" % attr)
#### Stuff used by Conftest.py (look there for explanations).
diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py
index 4d29b78..2b2380d 100644
--- a/src/engine/SCons/SConfTests.py
+++ b/src/engine/SCons/SConfTests.py
@@ -85,7 +85,7 @@ class SConfTestCase(unittest.TestCase):
if (not self.scons_env.Detect( self.scons_env.subst('$CXX') ) or
not self.scons_env.Detect( self.scons_env.subst('$CC') ) or
not self.scons_env.Detect( self.scons_env.subst('$LINK') )):
- raise Exception, "This test needs an installed compiler!"
+ raise Exception("This test needs an installed compiler!")
if self.scons_env['CXX'] == 'g++':
global existing_lib
existing_lib = 'm'
diff --git a/src/engine/SCons/SConsignTests.py b/src/engine/SCons/SConsignTests.py
index 7ae584a..c7f560e 100644
--- a/src/engine/SCons/SConsignTests.py
+++ b/src/engine/SCons/SConsignTests.py
@@ -143,14 +143,14 @@ class BaseTestCase(SConsignTestCase):
except KeyError:
pass
else:
- raise "unexpected entry %s" % e
+ raise Exception("unexpected entry %s" % e)
try:
e = f.get_entry('bbb')
except KeyError:
pass
else:
- raise "unexpected entry %s" % e
+ raise Exception("unexpected entry %s" % e)
f.merge()
diff --git a/src/engine/SCons/Scanner/FortranTests.py b/src/engine/SCons/Scanner/FortranTests.py
index b75da58..9ebe2e6 100644
--- a/src/engine/SCons/Scanner/FortranTests.py
+++ b/src/engine/SCons/Scanner/FortranTests.py
@@ -218,7 +218,7 @@ class DummyEnvironment:
elif len(args) == 1 and args[0] == 'FORTRANPATH':
return self.path
else:
- raise KeyError, "Dummy environment only has FORTRANPATH attribute."
+ raise KeyError("Dummy environment only has FORTRANPATH attribute.")
def has_key(self, key):
return key in self.Dictionary()
diff --git a/src/engine/SCons/Scanner/IDLTests.py b/src/engine/SCons/Scanner/IDLTests.py
index 096fc9f..54b2373 100644
--- a/src/engine/SCons/Scanner/IDLTests.py
+++ b/src/engine/SCons/Scanner/IDLTests.py
@@ -197,7 +197,7 @@ class DummyEnvironment:
elif len(args) == 1 and args[0] == 'CPPPATH':
return self.path
else:
- raise KeyError, "Dummy environment only has CPPPATH attribute."
+ raise KeyError("Dummy environment only has CPPPATH attribute.")
def subst(self, arg, target=None, source=None, conv=None):
return arg
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index 7909b0b..96fc4b7 100644
--- a/src/engine/SCons/Script/Main.py
+++ b/src/engine/SCons/Script/Main.py
@@ -683,7 +683,7 @@ def _load_site_scons_dir(topdir, site_dir_name=None):
site_dir = os.path.join(topdir.path, site_dir_name)
if not os.path.exists(site_dir):
if err_if_not_found:
- raise SCons.Errors.UserError, "site dir %s not found."%site_dir
+ raise SCons.Errors.UserError("site dir %s not found."%site_dir)
return
site_init_filename = "site_init.py"
@@ -710,7 +710,7 @@ def _load_site_scons_dir(topdir, site_dir_name=None):
m = sys.modules['SCons.Script']
except Exception, e:
fmt = 'cannot import site_init.py: missing SCons.Script module %s'
- raise SCons.Errors.InternalError, fmt % repr(e)
+ raise SCons.Errors.InternalError(fmt % repr(e))
try:
# This is the magic.
exec fp in m.__dict__
@@ -851,7 +851,7 @@ def _main(parser):
# Give them the options usage now, before we fail
# trying to read a non-existent SConstruct file.
raise SConsPrintHelpException
- raise SCons.Errors.UserError, "No SConstruct file found."
+ raise SCons.Errors.UserError("No SConstruct file found.")
if scripts[0] == "-":
d = fs.getcwd()
diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py
index 0f364d6..246d4eb 100644
--- a/src/engine/SCons/Script/SConsOptions.py
+++ b/src/engine/SCons/Script/SConsOptions.py
@@ -65,7 +65,7 @@ def diskcheck_convert(value):
elif v in diskcheck_all:
result.append(v)
else:
- raise ValueError, v
+ raise ValueError(v)
return result
class SConsValues(optparse.Values):
@@ -139,7 +139,7 @@ class SConsValues(optparse.Values):
Sets an option from an SConscript file.
"""
if not name in self.settable:
- raise SCons.Errors.UserError, "This option is not settable from a SConscript file: %s"%name
+ raise SCons.Errors.UserError("This option is not settable from a SConscript file: %s"%name)
if name == 'num_jobs':
try:
@@ -147,19 +147,19 @@ class SConsValues(optparse.Values):
if value < 1:
raise ValueError
except ValueError:
- raise SCons.Errors.UserError, "A positive integer is required: %s"%repr(value)
+ raise SCons.Errors.UserError("A positive integer is required: %s"%repr(value))
elif name == 'max_drift':
try:
value = int(value)
except ValueError:
- raise SCons.Errors.UserError, "An integer is required: %s"%repr(value)
+ raise SCons.Errors.UserError("An integer is required: %s"%repr(value))
elif name == 'duplicate':
try:
value = str(value)
except ValueError:
- raise SCons.Errors.UserError, "A string is required: %s"%repr(value)
+ raise SCons.Errors.UserError("A string is required: %s"%repr(value))
if not value in SCons.Node.FS.Valid_Duplicates:
- raise SCons.Errors.UserError, "Not a valid duplication style: %s" % value
+ raise SCons.Errors.UserError("Not a valid duplication style: %s" % value)
# Set the duplicate style right away so it can affect linking
# of SConscript files.
SCons.Node.FS.set_duplicate(value)
@@ -167,7 +167,7 @@ class SConsValues(optparse.Values):
try:
value = diskcheck_convert(value)
except ValueError, v:
- raise SCons.Errors.UserError, "Not a valid diskcheck value: %s"%v
+ raise SCons.Errors.UserError("Not a valid diskcheck value: %s"%v)
if 'diskcheck' not in self.__dict__:
# No --diskcheck= option was specified on the command line.
# Set this right away so it can affect the rest of the
@@ -177,12 +177,12 @@ class SConsValues(optparse.Values):
try:
value = int(value)
except ValueError:
- raise SCons.Errors.UserError, "An integer is required: %s"%repr(value)
+ raise SCons.Errors.UserError("An integer is required: %s"%repr(value))
elif name == 'md5_chunksize':
try:
value = int(value)
except ValueError:
- raise SCons.Errors.UserError, "An integer is required: %s"%repr(value)
+ raise SCons.Errors.UserError("An integer is required: %s"%repr(value))
elif name == 'warn':
if SCons.Util.is_String(value):
value = [value]
@@ -214,7 +214,7 @@ class SConsOption(optparse.Option):
def _check_nargs_optional(self):
if self.nargs == '?' and self._short_opts:
fmt = "option %s: nargs='?' is incompatible with short options"
- raise SCons.Errors.UserError, fmt % self._short_opts[0]
+ raise SCons.Errors.UserError(fmt % self._short_opts[0])
try:
_orig_CONST_ACTIONS = optparse.Option.CONST_ACTIONS
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 4e43382..7640ec8 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -115,7 +115,7 @@ def compute_exports(exports):
except KeyError:
retval[export] = glob[export]
except KeyError, x:
- raise SCons.Errors.UserError, "Export of non-existent variable '%s'"%x
+ raise SCons.Errors.UserError("Export of non-existent variable '%s'"%x)
return retval
@@ -147,7 +147,7 @@ def Return(*vars, **kw):
for v in var.split():
retval.append(call_stack[-1].globals[v])
except KeyError, x:
- raise SCons.Errors.UserError, "Return of non-existent variable '%s'"%x
+ raise SCons.Errors.UserError("Return of non-existent variable '%s'"%x)
if len(retval) == 1:
call_stack[-1].retval = retval[0]
@@ -337,7 +337,7 @@ def annotate(node):
tb = tb.tb_next
if not tb:
# We did not find any exec of an SConscript file: what?!
- raise SCons.Errors.InternalError, "could not find SConscript stack frame"
+ raise SCons.Errors.InternalError("could not find SConscript stack frame")
node.creator = traceback.extract_stack(tb)[0]
# The following line would cause each Node to be annotated using the
@@ -390,8 +390,7 @@ class SConsEnvironment(SCons.Environment.Base):
try:
dirs = kw["dirs"]
except KeyError:
- raise SCons.Errors.UserError, \
- "Invalid SConscript usage - no parameters"
+ raise SCons.Errors.UserError("Invalid SConscript usage - no parameters")
if not SCons.Util.is_List(dirs):
dirs = [ dirs ]
@@ -412,8 +411,7 @@ class SConsEnvironment(SCons.Environment.Base):
else:
- raise SCons.Errors.UserError, \
- "Invalid SConscript() usage - too many arguments"
+ raise SCons.Errors.UserError("Invalid SConscript() usage - too many arguments")
if not SCons.Util.is_List(files):
files = [ files ]
@@ -424,8 +422,7 @@ class SConsEnvironment(SCons.Environment.Base):
variant_dir = kw.get('variant_dir') or kw.get('build_dir')
if variant_dir:
if len(files) != 1:
- raise SCons.Errors.UserError, \
- "Invalid SConscript() usage - can only specify one SConscript with a variant_dir"
+ raise SCons.Errors.UserError("Invalid SConscript() usage - can only specify one SConscript with a variant_dir")
duplicate = kw.get('duplicate', 1)
src_dir = kw.get('src_dir')
if not src_dir:
@@ -456,7 +453,7 @@ class SConsEnvironment(SCons.Environment.Base):
def Configure(self, *args, **kw):
if not SCons.Script.sconscript_reading:
- raise SCons.Errors.UserError, "Calling Configure from Builders is not supported."
+ raise SCons.Errors.UserError("Calling Configure from Builders is not supported.")
kw['_depth'] = kw.get('_depth', 0) + 1
return SCons.Environment.Base.Configure(self, *args, **kw)
@@ -524,7 +521,7 @@ class SConsEnvironment(SCons.Environment.Base):
else:
globals[v] = global_exports[v]
except KeyError,x:
- raise SCons.Errors.UserError, "Import of non-existent variable '%s'"%x
+ raise SCons.Errors.UserError("Import of non-existent variable '%s'"%x)
def SConscript(self, *ls, **kw):
def subst_element(x, subst=self.subst):
@@ -566,7 +563,7 @@ SCons.Environment.Environment = SConsEnvironment
def Configure(*args, **kw):
if not SCons.Script.sconscript_reading:
- raise SCons.Errors.UserError, "Calling Configure from Builders is not supported."
+ raise SCons.Errors.UserError("Calling Configure from Builders is not supported.")
kw['_depth'] = 1
return SCons.SConf.SConf(*args, **kw)
diff --git a/src/engine/SCons/Subst.py b/src/engine/SCons/Subst.py
index a0a4859..caddd75 100644
--- a/src/engine/SCons/Subst.py
+++ b/src/engine/SCons/Subst.py
@@ -54,9 +54,9 @@ def raise_exception(exception, target, s):
name = exception.__class__.__name__
msg = "%s `%s' trying to evaluate `%s'" % (name, exception, s)
if target:
- raise SCons.Errors.BuildError, (target[0], msg)
+ raise SCons.Errors.BuildError(target[0], msg)
else:
- raise SCons.Errors.UserError, msg
+ raise SCons.Errors.UserError(msg)
@@ -238,7 +238,7 @@ class Target_or_Source:
except IndexError:
# If there is nothing in the list, then we have no attributes to
# pass through, so raise AttributeError for everything.
- raise AttributeError, "NodeList has no attribute: %s" % attr
+ raise AttributeError("NodeList has no attribute: %s" % attr)
return getattr(nl0, attr)
def __str__(self):
nl = self.nl._create_nodelist()
diff --git a/src/engine/SCons/SubstTests.py b/src/engine/SCons/SubstTests.py
index b423fa4..0334f14 100644
--- a/src/engine/SCons/SubstTests.py
+++ b/src/engine/SCons/SubstTests.py
@@ -524,7 +524,7 @@ class scons_subst_TestCase(SubstTestCase):
]
assert str(e) in expect, e
else:
- raise AssertionError, "did not catch expected UserError"
+ raise AssertionError("did not catch expected UserError")
def test_subst_syntax_errors(self):
"""Test scons_subst(): handling syntax errors"""
@@ -542,7 +542,7 @@ class scons_subst_TestCase(SubstTestCase):
]
assert str(e) in expect, e
else:
- raise AssertionError, "did not catch expected UserError"
+ raise AssertionError("did not catch expected UserError")
def test_subst_type_errors(self):
"""Test scons_subst(): handling type errors"""
@@ -558,7 +558,7 @@ class scons_subst_TestCase(SubstTestCase):
]
assert str(e) in expect, e
else:
- raise AssertionError, "did not catch expected UserError"
+ raise AssertionError("did not catch expected UserError")
try:
def func(a, b, c):
@@ -573,7 +573,7 @@ class scons_subst_TestCase(SubstTestCase):
]
assert str(e) in expect, repr(str(e))
else:
- raise AssertionError, "did not catch expected UserError"
+ raise AssertionError("did not catch expected UserError")
def test_subst_raw_function(self):
"""Test scons_subst(): fetch function with SUBST_RAW plus conv"""
@@ -978,7 +978,7 @@ class scons_subst_list_TestCase(SubstTestCase):
]
assert str(e) in expect, e
else:
- raise AssertionError, "did not catch expected UserError"
+ raise AssertionError("did not catch expected UserError")
def test_subst_syntax_errors(self):
"""Test scons_subst_list(): handling syntax errors"""
@@ -993,7 +993,7 @@ class scons_subst_list_TestCase(SubstTestCase):
]
assert str(e) in expect, e
else:
- raise AssertionError, "did not catch expected SyntaxError"
+ raise AssertionError("did not catch expected SyntaxError")
def test_subst_raw_function(self):
"""Test scons_subst_list(): fetch function with SUBST_RAW plus conv"""
diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py
index 1b42bcb..f60b2e2 100644
--- a/src/engine/SCons/Taskmaster.py
+++ b/src/engine/SCons/Taskmaster.py
@@ -1023,7 +1023,7 @@ class Taskmaster:
" Internal Error: no cycle found for node %s (%s) in state %s\n" % \
(node, repr(node), StateString[node.get_state()])
- raise SCons.Errors.UserError, desc
+ raise SCons.Errors.UserError(desc)
# Local Variables:
# tab-width:4
diff --git a/src/engine/SCons/TaskmasterTests.py b/src/engine/SCons/TaskmasterTests.py
index 917bb62..3dd22e3 100644
--- a/src/engine/SCons/TaskmasterTests.py
+++ b/src/engine/SCons/TaskmasterTests.py
@@ -539,7 +539,7 @@ class TaskmasterTestCase(unittest.TestCase):
"""
class MyTask(SCons.Taskmaster.Task):
def make_ready(self):
- raise MyException, "from make_ready()"
+ raise MyException("from make_ready()")
n1 = Node("n1")
tm = SCons.Taskmaster.Taskmaster(targets = [n1], tasker = MyTask)
@@ -615,7 +615,7 @@ class TaskmasterTestCase(unittest.TestCase):
"""
class StopNode(Node):
def children(self):
- raise SCons.Errors.StopError, "stop!"
+ raise SCons.Errors.StopError("stop!")
class ExitNode(Node):
def children(self):
sys.exit(77)
@@ -833,7 +833,7 @@ class TaskmasterTestCase(unittest.TestCase):
# Make sure we call an Executor's prepare() method.
class ExceptionExecutor:
def prepare(self):
- raise Exception, "Executor.prepare() exception"
+ raise Exception("Executor.prepare() exception")
def get_all_targets(self):
return self.nodes
def get_all_children(self):
@@ -856,7 +856,7 @@ class TaskmasterTestCase(unittest.TestCase):
except Exception, e:
assert str(e) == "Executor.prepare() exception", e
else:
- raise AssertionError, "did not catch expected exception"
+ raise AssertionError("did not catch expected exception")
def test_execute(self):
"""Test executing a task
@@ -881,7 +881,7 @@ class TaskmasterTestCase(unittest.TestCase):
except SCons.Errors.UserError:
pass
else:
- raise TestFailed, "did not catch expected UserError"
+ raise TestFailed("did not catch expected UserError")
def raise_BuildError():
raise SCons.Errors.BuildError
@@ -894,7 +894,7 @@ class TaskmasterTestCase(unittest.TestCase):
except SCons.Errors.BuildError:
pass
else:
- raise TestFailed, "did not catch expected BuildError"
+ raise TestFailed("did not catch expected BuildError")
# On a generic (non-BuildError) exception from a Builder,
# the target should throw a BuildError exception with the
@@ -914,7 +914,7 @@ class TaskmasterTestCase(unittest.TestCase):
exc_traceback = sys.exc_info()[2]
assert isinstance(e.exc_info[2], type(exc_traceback)), e.exc_info[2]
else:
- raise TestFailed, "did not catch expected BuildError"
+ raise TestFailed("did not catch expected BuildError")
built_text = None
cache_text = []
diff --git a/src/engine/SCons/Tool/JavaCommon.py b/src/engine/SCons/Tool/JavaCommon.py
index 1dfeefb..f2f7190 100644
--- a/src/engine/SCons/Tool/JavaCommon.py
+++ b/src/engine/SCons/Tool/JavaCommon.py
@@ -67,7 +67,7 @@ if java_parsing:
if not version in ('1.1', '1.2', '1.3','1.4', '1.5', '1.6',
'5', '6'):
msg = "Java version %s not supported" % version
- raise NotImplementedError, msg
+ raise NotImplementedError(msg)
self.version = version
self.listClasses = []
diff --git a/src/engine/SCons/Tool/MSCommon/sdk.py b/src/engine/SCons/Tool/MSCommon/sdk.py
index dc07192..75de6ec 100644
--- a/src/engine/SCons/Tool/MSCommon/sdk.py
+++ b/src/engine/SCons/Tool/MSCommon/sdk.py
@@ -312,7 +312,7 @@ def get_cur_sdk_dir_from_reg():
def get_sdk_by_version(mssdk):
if mssdk not in SupportedSDKMap:
msg = "SDK version %s is not supported" % repr(mssdk)
- raise SCons.Errors.UserError, msg
+ raise SCons.Errors.UserError(msg)
get_installed_sdks()
return InstalledSDKMap.get(mssdk)
@@ -338,7 +338,7 @@ def mssdk_setup_env(env):
sdk_version = env['MSSDK_VERSION']
if sdk_version is None:
msg = "SDK version %s is not installed" % repr(mssdk)
- raise SCons.Errors.UserError, msg
+ raise SCons.Errors.UserError(msg)
sdk_version = env.subst(sdk_version)
mssdk = get_sdk_by_version(sdk_version)
sdk_dir = mssdk.get_sdk_dir()
diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py
index 4baa9fd..b8aae84 100644
--- a/src/engine/SCons/Tool/MSCommon/vc.py
+++ b/src/engine/SCons/Tool/MSCommon/vc.py
@@ -138,9 +138,7 @@ _VCVER_TO_PRODUCT_DIR = {
}
def msvc_version_to_maj_min(msvc_version):
- msvc_version_numeric = string.join(filter(lambda x: x in string.digits + ".", msvc_version), '')
-
- t = msvc_version_numeric.split(".")
+ t = msvc_version.split(".")
if not len(t) == 2:
raise ValueError("Unrecognized version %s" % msvc_version)
try:
diff --git a/src/engine/SCons/Tool/MSCommon/vs.py b/src/engine/SCons/Tool/MSCommon/vs.py
index 264166f..6994bc6 100644
--- a/src/engine/SCons/Tool/MSCommon/vs.py
+++ b/src/engine/SCons/Tool/MSCommon/vs.py
@@ -387,7 +387,7 @@ def get_vs_by_version(msvs):
debug('vs.py:get_vs_by_version()')
if msvs not in SupportedVSMap:
msg = "Visual Studio version %s is not supported" % repr(msvs)
- raise SCons.Errors.UserError, msg
+ raise SCons.Errors.UserError(msg)
get_installed_visual_studios()
vs = InstalledVSMap.get(msvs)
debug('InstalledVSMap:%s'%InstalledVSMap)
@@ -451,7 +451,7 @@ def get_default_arch(env):
arch = 'x86'
elif not arch in msvs.get_supported_arch():
fmt = "Visual Studio version %s does not support architecture %s"
- raise SCons.Errors.UserError, fmt % (env['MSVS_VERSION'], arch)
+ raise SCons.Errors.UserError(fmt % (env['MSVS_VERSION'], arch))
return arch
diff --git a/src/engine/SCons/Tool/PharLapCommon.py b/src/engine/SCons/Tool/PharLapCommon.py
index dc124b5..9f925b9 100644
--- a/src/engine/SCons/Tool/PharLapCommon.py
+++ b/src/engine/SCons/Tool/PharLapCommon.py
@@ -45,7 +45,7 @@ def getPharLapPath():
be found."""
if not SCons.Util.can_read_reg:
- raise SCons.Errors.InternalError, "No Windows registry module was found"
+ raise SCons.Errors.InternalError("No Windows registry module was found")
try:
k=SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,
'SOFTWARE\\Pharlap\\ETS')
@@ -61,7 +61,7 @@ def getPharLapPath():
return os.path.normpath(val)
except SCons.Util.RegError:
- raise SCons.Errors.UserError, "Cannot find Phar Lap ETS path in the registry. Is it installed properly?"
+ raise SCons.Errors.UserError("Cannot find Phar Lap ETS path in the registry. Is it installed properly?")
REGEX_ETS_VER = re.compile(r'#define\s+ETS_VER\s+([0-9]+)')
@@ -78,7 +78,7 @@ def getPharLapVersion():
include_path = os.path.join(getPharLapPath(), os.path.normpath("include/embkern.h"))
if not os.path.exists(include_path):
- raise SCons.Errors.UserError, "Cannot find embkern.h in ETS include directory.\nIs Phar Lap ETS installed properly?"
+ raise SCons.Errors.UserError("Cannot find embkern.h in ETS include directory.\nIs Phar Lap ETS installed properly?")
mo = REGEX_ETS_VER.search(open(include_path, 'r').read())
if mo:
return int(mo.group(1))
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index b22fb59..e068bf5 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -114,7 +114,7 @@ class Tool:
file.close()
except ImportError, e:
if str(e)!="No module named %s"%self.name:
- raise SCons.Errors.EnvironmentError, e
+ raise SCons.Errors.EnvironmentError(e)
try:
import zipimport
except ImportError:
@@ -144,7 +144,7 @@ class Tool:
return module
except ImportError, e:
if str(e)!="No module named %s"%self.name:
- raise SCons.Errors.EnvironmentError, e
+ raise SCons.Errors.EnvironmentError(e)
try:
import zipimport
importer = zipimport.zipimporter( sys.modules['SCons.Tool'].__path__[0] )
@@ -153,10 +153,10 @@ class Tool:
return module
except ImportError, e:
m = "No tool named '%s': %s" % (self.name, e)
- raise SCons.Errors.EnvironmentError, m
+ raise SCons.Errors.EnvironmentError(m)
except ImportError, e:
m = "No tool named '%s': %s" % (self.name, e)
- raise SCons.Errors.EnvironmentError, m
+ raise SCons.Errors.EnvironmentError(m)
def __call__(self, env, *args, **kw):
if self.init_kw is not None:
diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py
index abdd479..dde0c98 100644
--- a/src/engine/SCons/Tool/install.py
+++ b/src/engine/SCons/Tool/install.py
@@ -54,7 +54,7 @@ def copyFunc(dest, source, env):
if os.path.isdir(source):
if os.path.exists(dest):
if not os.path.isdir(dest):
- raise SCons.Errors.UserError, "cannot overwrite non-directory `%s' with a directory `%s'" % (str(dest), str(source))
+ raise SCons.Errors.UserError("cannot overwrite non-directory `%s' with a directory `%s'" % (str(dest), str(source)))
else:
parent = os.path.split(dest)[0]
if not os.path.exists(parent):
@@ -135,7 +135,7 @@ BaseInstallBuilder = None
def InstallBuilderWrapper(env, target=None, source=None, dir=None, **kw):
if target and dir:
import SCons.Errors
- raise SCons.Errors.UserError, "Both target and dir defined for Install(), only one may be defined."
+ raise SCons.Errors.UserError("Both target and dir defined for Install(), only one may be defined.")
if not dir:
dir=target
@@ -149,7 +149,7 @@ def InstallBuilderWrapper(env, target=None, source=None, dir=None, **kw):
try:
dnodes = env.arg2nodes(dir, target_factory.Dir)
except TypeError:
- raise SCons.Errors.UserError, "Target `%s' of Install() is a file, but should be a directory. Perhaps you have the Install() arguments backwards?" % str(dir)
+ raise SCons.Errors.UserError("Target `%s' of Install() is a file, but should be a directory. Perhaps you have the Install() arguments backwards?" % str(dir))
sources = env.arg2nodes(source, env.fs.Entry)
tgt = []
for dnode in dnodes:
diff --git a/src/engine/SCons/Tool/intelc.py b/src/engine/SCons/Tool/intelc.py
index 1cc1312..fffda70 100644
--- a/src/engine/SCons/Tool/intelc.py
+++ b/src/engine/SCons/Tool/intelc.py
@@ -117,9 +117,8 @@ def check_abi(abi):
try:
abi = valid_abis[abi]
except KeyError:
- raise SCons.Errors.UserError, \
- "Intel compiler: Invalid ABI %s, valid values are %s"% \
- (abi, valid_abis.keys())
+ raise SCons.Errors.UserError("Intel compiler: Invalid ABI %s, valid values are %s"% \
+ (abi, valid_abis.keys()))
return abi
def vercmp(a, b):
@@ -156,16 +155,14 @@ def get_intel_registry_value(valuename, version=None, abi=None):
try:
k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, K)
except SCons.Util.RegError:
- raise MissingRegistryError, \
- "%s was not found in the registry, for Intel compiler version %s, abi='%s'"%(K, version,abi)
+ raise MissingRegistryError("%s was not found in the registry, for Intel compiler version %s, abi='%s'"%(K, version,abi))
# Get the value:
try:
v = SCons.Util.RegQueryValueEx(k, valuename)[0]
return v # or v.encode('iso-8859-1', 'replace') to remove unicode?
except SCons.Util.RegError:
- raise MissingRegistryError, \
- "%s\\%s was not found in the registry."%(K, valuename)
+ raise MissingRegistryError("%s\\%s was not found in the registry."%(K, valuename))
def get_all_compiler_versions():
@@ -255,13 +252,12 @@ def get_intel_compiler_top(version, abi):
if is_windows:
if not SCons.Util.can_read_reg:
- raise NoRegistryModuleError, "No Windows registry module was found"
+ raise NoRegistryModuleError("No Windows registry module was found")
top = get_intel_registry_value('ProductDir', version, abi)
# pre-11, icl was in Bin. 11 and later, it's in Bin/<abi> apparently.
if not os.path.exists(os.path.join(top, "Bin", "icl.exe")) \
and not os.path.exists(os.path.join(top, "Bin", abi, "icl.exe")):
- raise MissingDirError, \
- "Can't find Intel compiler in %s"%(top)
+ raise MissingDirError("Can't find Intel compiler in %s"%(top))
elif is_mac or is_linux:
# first dir is new (>=9.0) style, second is old (8.0) style.
dirs=('/opt/intel/cc/%s', '/opt/intel_cc_%s')
@@ -273,8 +269,7 @@ def get_intel_compiler_top(version, abi):
top = d%version
break
if not top:
- raise MissingDirError, \
- "Can't find version %s Intel compiler in %s (abi='%s')"%(version,top, abi)
+ raise MissingDirError("Can't find version %s Intel compiler in %s (abi='%s')"%(version,top, abi))
return top
@@ -310,9 +305,8 @@ def generate(env, version=None, abi=None, topdir=None, verbose=0):
# get_version_from_list does that mapping.
v = get_version_from_list(version, vlist)
if not v:
- raise SCons.Errors.UserError, \
- "Invalid Intel compiler version %s: "%version + \
- "installed versions are %s"%(', '.join(vlist))
+ raise SCons.Errors.UserError("Invalid Intel compiler version %s: "%version + \
+ "installed versions are %s"%(', '.join(vlist)))
version = v
# if abi is unspecified, use ia32
diff --git a/src/engine/SCons/Tool/mingw.py b/src/engine/SCons/Tool/mingw.py
index 8d40a0b..98156dd 100644
--- a/src/engine/SCons/Tool/mingw.py
+++ b/src/engine/SCons/Tool/mingw.py
@@ -72,7 +72,7 @@ def shlib_emitter(target, source, env):
no_import_lib = env.get('no_import_lib', 0)
if not dll:
- raise SCons.Errors.UserError, "A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")
+ raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX"))
if not no_import_lib and \
not env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX'):
diff --git a/src/engine/SCons/Tool/mslink.py b/src/engine/SCons/Tool/mslink.py
index b1ba1df..e0eec8c 100644
--- a/src/engine/SCons/Tool/mslink.py
+++ b/src/engine/SCons/Tool/mslink.py
@@ -103,7 +103,7 @@ def _dllEmitter(target, source, env, paramtp):
no_import_lib = env.get('no_import_lib', 0)
if not dll:
- raise SCons.Errors.UserError, 'A shared library should have exactly one target with the suffix: %s' % env.subst('$%sSUFFIX' % paramtp)
+ raise SCons.Errors.UserError('A shared library should have exactly one target with the suffix: %s' % env.subst('$%sSUFFIX' % paramtp))
insert_def = env.subst("$WINDOWS_INSERT_DEF")
if not insert_def in ['', '0', 0] and \
@@ -161,7 +161,7 @@ def prog_emitter(target, source, env):
exe = env.FindIxes(target, "PROGPREFIX", "PROGSUFFIX")
if not exe:
- raise SCons.Errors.UserError, "An executable should have exactly one target with the suffix: %s" % env.subst("$PROGSUFFIX")
+ raise SCons.Errors.UserError("An executable should have exactly one target with the suffix: %s" % env.subst("$PROGSUFFIX"))
version_num, suite = SCons.Tool.msvs.msvs_parse_version(env.get('MSVS_VERSION', '6.0'))
if version_num >= 8.0 and env.get('WINDOWS_INSERT_MANIFEST', 0):
@@ -182,7 +182,7 @@ def RegServerFunc(target, source, env):
if 'register' in env and env['register']:
ret = regServerAction([target[0]], [source[0]], env)
if ret:
- raise SCons.Errors.UserError, "Unable to register %s" % target[0]
+ raise SCons.Errors.UserError("Unable to register %s" % target[0])
else:
print "Registered %s sucessfully" % target[0]
return ret
diff --git a/src/engine/SCons/Tool/msvc.py b/src/engine/SCons/Tool/msvc.py
index fde93ea..41e793a 100644
--- a/src/engine/SCons/Tool/msvc.py
+++ b/src/engine/SCons/Tool/msvc.py
@@ -56,9 +56,9 @@ def validate_vars(env):
"""Validate the PCH and PCHSTOP construction variables."""
if 'PCH' in env and env['PCH']:
if 'PCHSTOP' not in env:
- raise SCons.Errors.UserError, "The PCHSTOP construction must be defined if PCH is defined."
+ raise SCons.Errors.UserError("The PCHSTOP construction must be defined if PCH is defined.")
if not SCons.Util.is_String(env['PCHSTOP']):
- raise SCons.Errors.UserError, "The PCHSTOP construction variable must be a string: %r"%env['PCHSTOP']
+ raise SCons.Errors.UserError("The PCHSTOP construction variable must be a string: %r"%env['PCHSTOP'])
def pch_emitter(target, source, env):
"""Adds the object file target."""
diff --git a/src/engine/SCons/Tool/msvs.py b/src/engine/SCons/Tool/msvs.py
index 6986488..304c35e 100644
--- a/src/engine/SCons/Tool/msvs.py
+++ b/src/engine/SCons/Tool/msvs.py
@@ -177,9 +177,8 @@ class _DSPGenerator:
self.dspabs = get_abspath()
if 'variant' not in env:
- raise SCons.Errors.InternalError, \
- "You must specify a 'variant' argument (i.e. 'Debug' or " +\
- "'Release') to create an MSVSProject."
+ raise SCons.Errors.InternalError("You must specify a 'variant' argument (i.e. 'Debug' or " +\
+ "'Release') to create an MSVSProject.")
elif SCons.Util.is_String(env['variant']):
variants = [env['variant']]
elif SCons.Util.is_List(env['variant']):
@@ -191,8 +190,7 @@ class _DSPGenerator:
buildtarget = [env['buildtarget']]
elif SCons.Util.is_List(env['buildtarget']):
if len(env['buildtarget']) != len(variants):
- raise SCons.Errors.InternalError, \
- "Sizes of 'buildtarget' and 'variant' lists must be the same."
+ raise SCons.Errors.InternalError("Sizes of 'buildtarget' and 'variant' lists must be the same.")
buildtarget = []
for bt in env['buildtarget']:
if SCons.Util.is_String(bt):
@@ -213,8 +211,7 @@ class _DSPGenerator:
outdir = [env['outdir']]
elif SCons.Util.is_List(env['outdir']):
if len(env['outdir']) != len(variants):
- raise SCons.Errors.InternalError, \
- "Sizes of 'outdir' and 'variant' lists must be the same."
+ raise SCons.Errors.InternalError("Sizes of 'outdir' and 'variant' lists must be the same.")
outdir = []
for s in env['outdir']:
if SCons.Util.is_String(s):
@@ -235,8 +232,7 @@ class _DSPGenerator:
runfile = [env['runfile']]
elif SCons.Util.is_List(env['runfile']):
if len(env['runfile']) != len(variants):
- raise SCons.Errors.InternalError, \
- "Sizes of 'runfile' and 'variant' lists must be the same."
+ raise SCons.Errors.InternalError("Sizes of 'runfile' and 'variant' lists must be the same.")
runfile = []
for s in env['runfile']:
if SCons.Util.is_String(s):
@@ -521,7 +517,7 @@ class _GenerateV6DSP(_DSPGenerator):
try:
self.file = open(self.dspabs,'w')
except IOError, detail:
- raise SCons.Errors.InternalError, 'Unable to open "' + self.dspabs + '" for writing:' + str(detail)
+ raise SCons.Errors.InternalError('Unable to open "' + self.dspabs + '" for writing:' + str(detail))
else:
self.PrintHeader()
self.PrintProject()
@@ -825,7 +821,7 @@ class _GenerateV7DSP(_DSPGenerator):
try:
self.file = open(self.dspabs,'w')
except IOError, detail:
- raise SCons.Errors.InternalError, 'Unable to open "' + self.dspabs + '" for writing:' + str(detail)
+ raise SCons.Errors.InternalError('Unable to open "' + self.dspabs + '" for writing:' + str(detail))
else:
self.PrintHeader()
self.PrintProject()
@@ -838,16 +834,13 @@ class _DSWGenerator:
self.env = env
if 'projects' not in env:
- raise SCons.Errors.UserError, \
- "You must specify a 'projects' argument to create an MSVSSolution."
+ raise SCons.Errors.UserError("You must specify a 'projects' argument to create an MSVSSolution.")
projects = env['projects']
if not SCons.Util.is_List(projects):
- raise SCons.Errors.InternalError, \
- "The 'projects' argument must be a list of nodes."
+ raise SCons.Errors.InternalError("The 'projects' argument must be a list of nodes.")
projects = SCons.Util.flatten(projects)
if len(projects) < 1:
- raise SCons.Errors.UserError, \
- "You must specify at least one project to create an MSVSSolution."
+ raise SCons.Errors.UserError("You must specify at least one project to create an MSVSSolution.")
self.dspfiles = list(map(str, projects))
if 'name' in self.env:
@@ -904,9 +897,8 @@ class _GenerateV7DSW(_DSWGenerator):
print "Adding '" + self.name + ' - ' + config.variant + '|' + config.platform + "' to '" + str(dswfile) + "'"
if 'variant' not in env:
- raise SCons.Errors.InternalError, \
- "You must specify a 'variant' argument (i.e. 'Debug' or " +\
- "'Release') to create an MSVS Solution File."
+ raise SCons.Errors.InternalError("You must specify a 'variant' argument (i.e. 'Debug' or " +\
+ "'Release') to create an MSVS Solution File.")
elif SCons.Util.is_String(env['variant']):
AddConfig(self, env['variant'])
elif SCons.Util.is_List(env['variant']):
@@ -1053,7 +1045,7 @@ class _GenerateV7DSW(_DSWGenerator):
try:
self.file = open(self.dswfile,'w')
except IOError, detail:
- raise SCons.Errors.InternalError, 'Unable to open "' + self.dswfile + '" for writing:' + str(detail)
+ raise SCons.Errors.InternalError('Unable to open "' + self.dswfile + '" for writing:' + str(detail))
else:
self.PrintSolution()
self.file.close()
@@ -1102,7 +1094,7 @@ class _GenerateV6DSW(_DSWGenerator):
try:
self.file = open(self.dswfile,'w')
except IOError, detail:
- raise SCons.Errors.InternalError, 'Unable to open "' + self.dswfile + '" for writing:' + str(detail)
+ raise SCons.Errors.InternalError('Unable to open "' + self.dswfile + '" for writing:' + str(detail))
else:
self.PrintWorkspace()
self.file.close()
@@ -1210,12 +1202,10 @@ def projectEmitter(target, source, env):
source = source + ' "%s"' % bt
else:
try: source = source + ' "%s"' % bt.get_abspath()
- except AttributeError: raise SCons.Errors.InternalError, \
- "buildtarget can be a string, a node, a list of strings or nodes, or None"
+ except AttributeError: raise SCons.Errors.InternalError("buildtarget can be a string, a node, a list of strings or nodes, or None")
else:
try: source = source + ' "%s"' % env['buildtarget'].get_abspath()
- except AttributeError: raise SCons.Errors.InternalError, \
- "buildtarget can be a string, a node, a list of strings or nodes, or None"
+ except AttributeError: raise SCons.Errors.InternalError("buildtarget can be a string, a node, a list of strings or nodes, or None")
if 'outdir' in env and env['outdir'] != None:
if SCons.Util.is_String(env['outdir']):
@@ -1226,18 +1216,16 @@ def projectEmitter(target, source, env):
source = source + ' "%s"' % s
else:
try: source = source + ' "%s"' % s.get_abspath()
- except AttributeError: raise SCons.Errors.InternalError, \
- "outdir can be a string, a node, a list of strings or nodes, or None"
+ except AttributeError: raise SCons.Errors.InternalError("outdir can be a string, a node, a list of strings or nodes, or None")
else:
try: source = source + ' "%s"' % env['outdir'].get_abspath()
- except AttributeError: raise SCons.Errors.InternalError, \
- "outdir can be a string, a node, a list of strings or nodes, or None"
+ except AttributeError: raise SCons.Errors.InternalError("outdir can be a string, a node, a list of strings or nodes, or None")
if 'name' in env:
if SCons.Util.is_String(env['name']):
source = source + ' "%s"' % env['name']
else:
- raise SCons.Errors.InternalError, "name must be a string"
+ raise SCons.Errors.InternalError("name must be a string")
if 'variant' in env:
if SCons.Util.is_String(env['variant']):
@@ -1247,11 +1235,11 @@ def projectEmitter(target, source, env):
if SCons.Util.is_String(variant):
source = source + ' "%s"' % variant
else:
- raise SCons.Errors.InternalError, "name must be a string or a list of strings"
+ raise SCons.Errors.InternalError("name must be a string or a list of strings")
else:
- raise SCons.Errors.InternalError, "variant must be a string or a list of strings"
+ raise SCons.Errors.InternalError("variant must be a string or a list of strings")
else:
- raise SCons.Errors.InternalError, "variant must be specified"
+ raise SCons.Errors.InternalError("variant must be specified")
for s in _DSPGenerator.srcargs:
if s in env:
@@ -1262,9 +1250,9 @@ def projectEmitter(target, source, env):
if SCons.Util.is_String(t):
source = source + ' "%s"' % t
else:
- raise SCons.Errors.InternalError, s + " must be a string or a list of strings"
+ raise SCons.Errors.InternalError(s + " must be a string or a list of strings")
else:
- raise SCons.Errors.InternalError, s + " must be a string or a list of strings"
+ raise SCons.Errors.InternalError(s + " must be a string or a list of strings")
source = source + ' "%s"' % str(target[0])
source = [SCons.Node.Python.Value(source)]
@@ -1300,7 +1288,7 @@ def solutionEmitter(target, source, env):
if SCons.Util.is_String(env['name']):
source = source + ' "%s"' % env['name']
else:
- raise SCons.Errors.InternalError, "name must be a string"
+ raise SCons.Errors.InternalError("name must be a string")
if 'variant' in env:
if SCons.Util.is_String(env['variant']):
@@ -1310,17 +1298,17 @@ def solutionEmitter(target, source, env):
if SCons.Util.is_String(variant):
source = source + ' "%s"' % variant
else:
- raise SCons.Errors.InternalError, "name must be a string or a list of strings"
+ raise SCons.Errors.InternalError("name must be a string or a list of strings")
else:
- raise SCons.Errors.InternalError, "variant must be a string or a list of strings"
+ raise SCons.Errors.InternalError("variant must be a string or a list of strings")
else:
- raise SCons.Errors.InternalError, "variant must be specified"
+ raise SCons.Errors.InternalError("variant must be specified")
if 'slnguid' in env:
if SCons.Util.is_String(env['slnguid']):
source = source + ' "%s"' % env['slnguid']
else:
- raise SCons.Errors.InternalError, "slnguid must be a string"
+ raise SCons.Errors.InternalError("slnguid must be a string")
if 'projects' in env:
if SCons.Util.is_String(env['projects']):
diff --git a/src/engine/SCons/Tool/mwld.py b/src/engine/SCons/Tool/mwld.py
index e84b812..e762d55 100644
--- a/src/engine/SCons/Tool/mwld.py
+++ b/src/engine/SCons/Tool/mwld.py
@@ -85,7 +85,7 @@ def shlib_emitter(target, source, env):
no_import_lib = env.get('no_import_lib', 0)
if not dll:
- raise SCons.Errors.UserError, "A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")
+ raise SCons.Errors.UserError("A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX"))
if not no_import_lib and \
not env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX'):
diff --git a/src/engine/SCons/Tool/packaging/__init__.py b/src/engine/SCons/Tool/packaging/__init__.py
index b80f128..462228f 100644
--- a/src/engine/SCons/Tool/packaging/__init__.py
+++ b/src/engine/SCons/Tool/packaging/__init__.py
@@ -59,7 +59,7 @@ def Tag(env, target, source, *more_tags, **kw_tags):
kw_tags[first_tag[0]] = ''
if len(kw_tags) == 0 and len(more_tags) == 0:
- raise UserError, "No tags given."
+ raise UserError("No tags given.")
# XXX: sanity checks
for x in more_tags:
@@ -92,7 +92,7 @@ def Package(env, target=None, source=None, **kw):
source = env.FindInstalledFiles()
if len(source)==0:
- raise UserError, "No source for Package() given"
+ raise UserError("No source for Package() given")
# decide which types of packages shall be built. Can be defined through
# four mechanisms: command line argument, keyword argument,
@@ -111,7 +111,7 @@ def Package(env, target=None, source=None, **kw):
elif 'Zip' in env['BUILDERS']:
kw['PACKAGETYPE']='zip'
else:
- raise UserError, "No type for Package() given"
+ raise UserError("No type for Package() given")
PACKAGETYPE=kw['PACKAGETYPE']
if not is_List(PACKAGETYPE):
diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py
index 6816af0..d61db37 100644
--- a/src/engine/SCons/Util.py
+++ b/src/engine/SCons/Util.py
@@ -1136,7 +1136,7 @@ class Selector(OrderedDict):
# to the same suffix. If one suffix is literal
# and a variable suffix contains this literal,
# the literal wins and we don't raise an error.
- raise KeyError, (s_dict[s_k][0], k, s_k)
+ raise KeyError(s_dict[s_k][0], k, s_k)
s_dict[s_k] = (k,v)
try:
return s_dict[ext][1]
diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py
index e044065..15ee2a6 100644
--- a/src/engine/SCons/UtilTests.py
+++ b/src/engine/SCons/UtilTests.py
@@ -774,7 +774,7 @@ class NodeListTestCase(unittest.TestCase):
r = str(nl)
assert r == '', r
for node in nl:
- raise Exception, "should not enter this loop"
+ raise Exception("should not enter this loop")
class flattenTestCase(unittest.TestCase):
diff --git a/src/engine/SCons/Variables/PathVariableTests.py b/src/engine/SCons/Variables/PathVariableTests.py
index 1643252..084154b 100644
--- a/src/engine/SCons/Variables/PathVariableTests.py
+++ b/src/engine/SCons/Variables/PathVariableTests.py
@@ -68,7 +68,7 @@ class PathVariableTestCase(unittest.TestCase):
except SCons.Errors.UserError, e:
assert str(e) == 'Path for option X does not exist: %s' % dne, e
except:
- raise "did not catch expected UserError"
+ raise Exception("did not catch expected UserError")
def test_PathIsDir(self):
"""Test the PathIsDir validator"""
@@ -92,7 +92,7 @@ class PathVariableTestCase(unittest.TestCase):
except SCons.Errors.UserError, e:
assert str(e) == 'Directory path for option X is a file: %s' % f, e
except:
- raise "did not catch expected UserError"
+ raise Exception("did not catch expected UserError")
dne = test.workpath('does_not_exist')
try:
@@ -100,7 +100,7 @@ class PathVariableTestCase(unittest.TestCase):
except SCons.Errors.UserError, e:
assert str(e) == 'Directory path for option X does not exist: %s' % dne, e
except:
- raise "did not catch expected UserError"
+ raise Exception("did not catch expected UserError")
def test_PathIsDirCreate(self):
"""Test the PathIsDirCreate validator"""
@@ -125,7 +125,7 @@ class PathVariableTestCase(unittest.TestCase):
except SCons.Errors.UserError, e:
assert str(e) == 'Path for option X is a file, not a directory: %s' % f, e
except:
- raise "did not catch expected UserError"
+ raise Exception("did not catch expected UserError")
def test_PathIsFile(self):
"""Test the PathIsFile validator"""
@@ -149,7 +149,7 @@ class PathVariableTestCase(unittest.TestCase):
except SCons.Errors.UserError, e:
assert str(e) == 'File path for option X does not exist: %s' % d, e
except:
- raise "did not catch expected UserError"
+ raise Exception("did not catch expected UserError")
dne = test.workpath('does_not_exist')
try:
@@ -157,7 +157,7 @@ class PathVariableTestCase(unittest.TestCase):
except SCons.Errors.UserError, e:
assert str(e) == 'File path for option X does not exist: %s' % dne, e
except:
- raise "did not catch expected UserError"
+ raise Exception("did not catch expected UserError")
def test_PathAccept(self):
"""Test the PathAccept validator"""
@@ -202,10 +202,10 @@ class PathVariableTestCase(unittest.TestCase):
expect = 'Path for option X does not exist: %s' % dne
assert str(e) == expect, e
else:
- raise "did not catch expected UserError"
+ raise Exception("did not catch expected UserError")
def my_validator(key, val, env):
- raise Exception, "my_validator() got called for %s, %s!" % (key, val)
+ raise Exception("my_validator() got called for %s, %s!" % (key, val))
opts = SCons.Variables.Variables()
opts.Add(SCons.Variables.PathVariable('test2',
@@ -220,7 +220,7 @@ class PathVariableTestCase(unittest.TestCase):
except Exception, e:
assert str(e) == 'my_validator() got called for Y, value!', e
else:
- raise "did not catch expected exception from my_validator()"
+ raise Exception("did not catch expected exception from my_validator()")
diff --git a/src/engine/SCons/Variables/__init__.py b/src/engine/SCons/Variables/__init__.py
index 09d4e29..171c098 100644
--- a/src/engine/SCons/Variables/__init__.py
+++ b/src/engine/SCons/Variables/__init__.py
@@ -129,7 +129,7 @@ class Variables:
if not SCons.Util.is_String(key) or \
not SCons.Environment.is_valid_construction_var(key):
- raise SCons.Errors.UserError, "Illegal Variables.Add() key `%s'" % str(key)
+ raise SCons.Errors.UserError("Illegal Variables.Add() key `%s'" % str(key))
self._do_add(key, help, default, validator, converter)
@@ -211,7 +211,7 @@ class Variables:
except TypeError:
env[option.key] = option.converter(value, env)
except ValueError, x:
- raise SCons.Errors.UserError, 'Error converting option: %s\n%s'%(option.key, x)
+ raise SCons.Errors.UserError('Error converting option: %s\n%s'%(option.key, x))
# Finally validate the values:
@@ -273,7 +273,7 @@ class Variables:
fh.close()
except IOError, x:
- raise SCons.Errors.UserError, 'Error writing options to file: %s\n%s' % (filename, x)
+ raise SCons.Errors.UserError('Error writing options to file: %s\n%s' % (filename, x))
def GenerateHelpText(self, env, sort=None):
"""
diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py
index 1792dc4..a68ef72 100644
--- a/src/engine/SCons/compat/__init__.py
+++ b/src/engine/SCons/compat/__init__.py
@@ -308,7 +308,7 @@ except AttributeError:
except OSError:
if os.path.isdir(src):
if shutil.destinsrc(src, dst):
- raise Error, "Cannot move a directory '%s' into itself '%s'." % (src, dst)
+ raise Error("Cannot move a directory '%s' into itself '%s'." % (src, dst))
shutil.copytree(src, dst, symlinks=True)
shutil.rmtree(src)
else:
diff --git a/src/engine/SCons/compat/_scons_hashlib.py b/src/engine/SCons/compat/_scons_hashlib.py
index 66a3255..102304a7 100644
--- a/src/engine/SCons/compat/_scons_hashlib.py
+++ b/src/engine/SCons/compat/_scons_hashlib.py
@@ -42,7 +42,7 @@ class md5obj:
def __init__(self, name, string=''):
if not name in ('MD5', 'md5'):
- raise ValueError, "unsupported hash type"
+ raise ValueError("unsupported hash type")
self.name = 'md5'
self.m = self.md5_module.md5()
diff --git a/src/engine/SCons/compat/_scons_optparse.py b/src/engine/SCons/compat/_scons_optparse.py
index 9c3df52..db6fd0d 100644
--- a/src/engine/SCons/compat/_scons_optparse.py
+++ b/src/engine/SCons/compat/_scons_optparse.py
@@ -257,10 +257,10 @@ class HelpFormatter:
self.level = self.level - 1
def format_usage(self, usage):
- raise NotImplementedError, "subclasses must implement"
+ raise NotImplementedError("subclasses must implement")
def format_heading(self, heading):
- raise NotImplementedError, "subclasses must implement"
+ raise NotImplementedError("subclasses must implement")
def _format_text(self, text):
"""
@@ -831,7 +831,7 @@ class Option:
parser.print_version()
parser.exit()
else:
- raise RuntimeError, "unknown action %r" % self.action
+ raise RuntimeError("unknown action %r" % self.action)
return 1
@@ -902,7 +902,7 @@ class Values:
elif mode == "loose":
self._update_loose(dict)
else:
- raise ValueError, "invalid update mode: %r" % mode
+ raise ValueError("invalid update mode: %r" % mode)
def read_module(self, modname, mode="careful"):
__import__(modname)
@@ -981,7 +981,7 @@ class OptionContainer:
def set_conflict_handler(self, handler):
if handler not in ("error", "resolve"):
- raise ValueError, "invalid conflict_resolution value %r" % handler
+ raise ValueError("invalid conflict_resolution value %r" % handler)
self.conflict_handler = handler
def set_description(self, description):
@@ -1036,9 +1036,9 @@ class OptionContainer:
elif len(args) == 1 and not kwargs:
option = args[0]
if not isinstance(option, Option):
- raise TypeError, "not an Option instance: %r" % option
+ raise TypeError("not an Option instance: %r" % option)
else:
- raise TypeError, "invalid arguments"
+ raise TypeError("invalid arguments")
self._check_conflict(option)
@@ -1347,11 +1347,11 @@ class OptionParser (OptionContainer):
elif len(args) == 1 and not kwargs:
group = args[0]
if not isinstance(group, OptionGroup):
- raise TypeError, "not an OptionGroup instance: %r" % group
+ raise TypeError("not an OptionGroup instance: %r" % group)
if group.parser is not self:
- raise ValueError, "invalid OptionGroup (wrong parser)"
+ raise ValueError("invalid OptionGroup (wrong parser)")
else:
- raise TypeError, "invalid arguments"
+ raise TypeError("invalid arguments")
self.option_groups.append(group)
return group
diff --git a/src/engine/SCons/compat/_scons_sets.py b/src/engine/SCons/compat/_scons_sets.py
index 765867b..211ff16 100644
--- a/src/engine/SCons/compat/_scons_sets.py
+++ b/src/engine/SCons/compat/_scons_sets.py
@@ -91,7 +91,7 @@ class BaseSet(object):
"""This is an abstract class."""
# Don't call this from a concrete subclass!
if self.__class__ is BaseSet:
- raise TypeError, ("BaseSet is an abstract class. "
+ raise TypeError("BaseSet is an abstract class. "
"Use Set or ImmutableSet.")
# Standard protocols: __len__, __repr__, __str__, __iter__
@@ -130,7 +130,7 @@ class BaseSet(object):
# case).
def __cmp__(self, other):
- raise TypeError, "can't compare sets using cmp()"
+ raise TypeError("can't compare sets using cmp()")
# Equality comparisons using the underlying dicts. Mixed-type comparisons
# are allowed here, where Set == z for non-Set z always returns False,
@@ -341,7 +341,7 @@ class BaseSet(object):
# Check that the other argument to a binary operation is also
# a set, raising a TypeError otherwise.
if not isinstance(other, BaseSet):
- raise TypeError, "Binary operation only permitted between sets"
+ raise TypeError("Binary operation only permitted between sets")
def _compute_hash(self):
# Calculate hash code for a set by xor'ing the hash codes of
@@ -439,7 +439,7 @@ class Set(BaseSet):
def __hash__(self):
"""A Set cannot be hashed."""
# We inherit object.__hash__, so we must deny this explicitly
- raise TypeError, "Can't hash a Set, only an ImmutableSet."
+ raise TypeError("Can't hash a Set, only an ImmutableSet.")
# In-place union, intersection, differences.
# Subtle: The xyz_update() functions deliberately return None,
diff --git a/src/engine/SCons/compat/_scons_shlex.py b/src/engine/SCons/compat/_scons_shlex.py
index dfca2c1..6ed39cf 100644
--- a/src/engine/SCons/compat/_scons_shlex.py
+++ b/src/engine/SCons/compat/_scons_shlex.py
@@ -196,7 +196,7 @@ class shlex:
if self.debug >= 2:
print "shlex: I see EOF in quotes state"
# XXX what error should be raised here?
- raise ValueError, "No closing quotation"
+ raise ValueError("No closing quotation")
if nextchar == self.state:
if not self.posix:
self.token = self.token + nextchar
@@ -215,7 +215,7 @@ class shlex:
if self.debug >= 2:
print "shlex: I see EOF in escape state"
# XXX what error should be raised here?
- raise ValueError, "No escaped character"
+ raise ValueError("No escaped character")
# In posix shells, only the quote itself or the escape
# character may be escaped within quotes.
if escapedstate in self.quotes and \
diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py
index 5e159ec..80b1c8b 100644
--- a/src/engine/SCons/cpp.py
+++ b/src/engine/SCons/cpp.py
@@ -202,7 +202,7 @@ class FunctionEvaluator:
with the specified values.
"""
if len(self.args) != len(values):
- raise ValueError, "Incorrect number of arguments to `%s'" % self.name
+ raise ValueError("Incorrect number of arguments to `%s'" % self.name)
# Create a dictionary that maps the macro arguments to the
# corresponding values in this "call." We'll use this when we
# eval() the expansion so that arguments will get expanded to
diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py
index 8e40a5f..5acd0f2 100644
--- a/src/engine/SCons/dblite.py
+++ b/src/engine/SCons/dblite.py
@@ -144,9 +144,9 @@ class dblite:
def __setitem__(self, key, value):
self._check_writable()
if (not is_string(key)):
- raise TypeError, "key `%s' must be a string but is %s" % (key, type(key))
+ raise TypeError("key `%s' must be a string but is %s" % (key, type(key)))
if (not is_string(value)):
- raise TypeError, "value `%s' must be a string but is %s" % (value, type(value))
+ raise TypeError("value `%s' must be a string but is %s" % (value, type(value)))
self._dict[key] = value
self._needs_sync = 0001
@@ -198,7 +198,7 @@ def _exercise():
except IOError, e:
assert str(e) == "Read-only database: tmp.dblite"
else:
- raise RuntimeError, "IOError expected."
+ raise RuntimeError("IOError expected.")
db = open("tmp", "w")
assert len(db) == 4
db["ping"] = "pong"
@@ -208,13 +208,13 @@ def _exercise():
except TypeError, e:
assert str(e) == "key `(1, 2)' must be a string but is <type 'tuple'>", str(e)
else:
- raise RuntimeError, "TypeError exception expected"
+ raise RuntimeError("TypeError exception expected")
try:
db["list"] = [1,2]
except TypeError, e:
assert str(e) == "value `[1, 2]' must be a string but is <type 'list'>", str(e)
else:
- raise RuntimeError, "TypeError exception expected"
+ raise RuntimeError("TypeError exception expected")
db = open("tmp", "r")
assert len(db) == 5
db = open("tmp", "n")
@@ -227,7 +227,7 @@ def _exercise():
except pickle.UnpicklingError:
pass
else:
- raise RuntimeError, "pickle exception expected."
+ raise RuntimeError("pickle exception expected.")
global ignore_corrupt_dbfiles
ignore_corrupt_dbfiles = 2
db = open("tmp", "r")
@@ -238,7 +238,7 @@ def _exercise():
except IOError, e:
assert str(e) == "[Errno 2] No such file or directory: 'tmp.dblite'", str(e)
else:
- raise RuntimeError, "IOError expected."
+ raise RuntimeError("IOError expected.")
print "OK"
if (__name__ == "__main__"):