expr = re.compile(s)
except re.error, e:
msg = "Regular expression error in %s: %s"
- raise re.error, msg % (repr(s), e[0])
+ raise re.error(msg % (repr(s), e[0]))
if not expr.search(lines[i]):
return
return 1
expr = re.compile(s, re.DOTALL)
except re.error, e:
msg = "Regular expression error in %s: %s"
- raise re.error, msg % (repr(s), e[0])
+ raise re.error(msg % (repr(s), e[0]))
if expr.match(lines):
return 1
expr = re.compile(s)
except re.error, e:
msg = "Regular expression error in %s: %s"
- raise re.error, msg % (repr(s), e[0])
+ raise re.error(msg % (repr(s), e[0]))
if not expr.search(bline):
result.append("%sc%s" % (i+1, i+1))
result.append('< ' + repr(a[i]))
"""
file = self.canonicalize(file)
if mode[0] != 'r':
- raise ValueError, "mode must begin with 'r'"
+ raise ValueError("mode must begin with 'r'")
return open(file, mode).read()
def rmdir(self, dir):
"""
file = self.canonicalize(file)
if mode[0] != 'w':
- raise ValueError, "mode must begin with 'w'"
+ raise ValueError("mode must begin with 'w'")
open(file, mode).write(content)
# Local Variables:
def matchPart(log, logfile, lastEnd, NoMatch=NoMatch):
m = re.match(log, logfile[lastEnd:])
if not m:
- raise NoMatch, lastEnd
+ raise NoMatch(lastEnd)
return m.end() + lastEnd
try:
#print len(os.linesep)
log = ""
if doCheckLog: lastEnd = matchPart(ls, logfile, lastEnd)
if doCheckLog and lastEnd != len(logfile):
- raise NoMatch, lastEnd
+ raise NoMatch(lastEnd)
except NoMatch, m:
print "Cannot match log file against log regexp."
try:
self.__testMethod = getattr(self,methodName)
except AttributeError:
- raise ValueError, "no such test method in %s: %s" % \
- (self.__class__, methodName)
+ raise ValueError("no such test method in %s: %s" % \
+ (self.__class__, methodName))
def setUp(self):
"Hook method for setting up the test fixture before exercising it."
__debug__ is false.
"""
if not expr:
- raise AssertionError, msg
+ raise AssertionError(msg)
failUnless = assert_
else:
if hasattr(excClass,'__name__'): excName = excClass.__name__
else: excName = str(excClass)
- raise AssertionError, excName
+ raise AssertionError(excName)
def fail(self, msg=None):
"""Fail immediately, with the given message."""
- raise AssertionError, msg
+ raise AssertionError(msg)
def __exc_info(self):
"""Return a version of sys.exc_info() with the traceback frame
"""
spec = name.split(':')
- if len(spec) > 2: raise ValueError, "illegal test name: %s" % name
+ if len(spec) > 2: raise ValueError("illegal test name: %s" % name)
if len(spec) == 1:
testName = spec[0]
caseName = None
parts = testName.split('.')
if module is None:
if len(parts) < 2:
- raise ValueError, "incomplete test name: %s" % name
+ raise ValueError("incomplete test name: %s" % name)
constructor = __import__('.'.join(parts[:-1]))
parts = parts[1:]
else:
for part in parts:
constructor = getattr(constructor, part)
if not callable(constructor):
- raise ValueError, "%s is not a callable object" % constructor
+ raise ValueError("%s is not a callable object" % constructor)
if caseName:
if caseName[-1] == '-':
prefix = caseName[:-1]
if not prefix:
- raise ValueError, "prefix too short: %s" % name
+ raise ValueError("prefix too short: %s" % name)
test = makeSuite(constructor, prefix=prefix)
else:
test = constructor(caseName)
else:
test = constructor()
if not hasattr(test,"countTestCases"):
- raise TypeError, \
- "object %s found with spec %s is not a test" % (test, name)
+ raise TypeError("object %s found with spec %s is not a test" % (test, name))
return test
if opt in ('-h','-H','--help'):
self.usageExit()
if len(args) == 0 and self.defaultTest is None:
- raise getopt.error, "No default test is defined."
+ raise getopt.error("No default test is defined.")
if len(args) > 0:
self.testNames = args
else:
elif t == '4444':
func = dep.func4
else:
- raise Exception, "bad key %s" % t
+ raise Exception("bad key %s" % t)
return func(arg)
special(self, key, value)
else:
if not SCons.Environment.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[key] = value
class env_Global_is_valid(Environment):
special(self, key, value)
else:
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[key] = value
class env_Method_is_valid(Environment):
special(self, key, value)
else:
if not self.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[key] = value
class env_regex_attribute_is_valid(Environment):
special(self, key, value)
else:
if not self._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
class env_global_regex_is_valid(Environment):
special(self, key, value)
else:
if not global_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
class env_special_set_has_key(Environment):
self._special_set[key](self, key, value)
else:
if not SCons.Environment.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[key] = value
class env_key_in_tuple(Environment):
self._special_set[key](self, key, value)
else:
if not SCons.Environment.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[key] = value
class env_key_in_list(Environment):
self._special_set[key](self, key, value)
else:
if not SCons.Environment.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[key] = value
class env_key_in_attribute(Environment):
self._special_set[key](self, key, value)
else:
if not SCons.Environment.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[key] = value
class env_try_except(Environment):
self._dict[key]
except KeyError:
if not SCons.Environment.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[key] = value
class env_not_has_key(Environment):
else:
if key not in self._dict \
and not SCons.Environment.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[key] = value
class env_Best_attribute(Environment):
else:
if key not in self._dict \
and not global_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
class env_Best_has_key(Environment):
else:
if key not in self._dict \
and not global_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
class env_Best_list(Environment):
else:
if key not in self._dict \
and not global_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
try:
self._special_set[key](self, key, value)
else:
if not key.isalnum() and not global_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
# We'll use the names of all the env_* classes we find later to build
# The elements to be picked out of the issue
PickList = [
- # sort key -- these are used to sort the entry
- 'target_milestone', 'priority', 'votes_desc', 'creation_ts',
- # payload -- these are displayed
- 'issue_id', 'votes', 'issue_type', 'target_milestone',
- 'priority', 'assigned_to', 'short_desc',
- ]
+ # sort key -- these are used to sort the entry
+ 'target_milestone', 'priority', 'votes_desc', 'creation_ts',
+ # payload -- these are displayed
+ 'issue_id', 'votes', 'issue_type', 'target_milestone',
+ 'priority', 'assigned_to', 'short_desc',
+ ]
# Conbert a leaf element into its value as a text string
# We assume it's "short enough" that there's only one substring
def Value(element):
- v = element.firstChild
- if v is None: return ''
- return v.nodeValue
+ v = element.firstChild
+ if v is None: return ''
+ return v.nodeValue
# Parse the XML issues file and produce a DOM for it
import sys
# and put them in our list of issues.
issues = []
for issuezilla in xml.childNodes:
- # The Issuezilla element contains the issues
- if issuezilla.nodeType != issuezilla.ELEMENT_NODE: continue
- for issue in issuezilla.childNodes:
- # The issue elements contain the info for an issue
- if issue.nodeType != issue.ELEMENT_NODE: continue
- # Accumulate the pieces we want to include
- d = {}
- for element in issue.childNodes:
- if element.nodeName in PickList:
- d[element.nodeName] = Value(element)
- # convert 'votes' to numeric, ascending and descending
- try:
- v = int('0' + d['votes'])
- except KeyError:
- pass
- else:
- d['votes_desc'] = -v
- d['votes'] = v
- # Marshal the elements and add them to the list
- issues.append([ d[ix] for ix in PickList ])
+ # The Issuezilla element contains the issues
+ if issuezilla.nodeType != issuezilla.ELEMENT_NODE: continue
+ for issue in issuezilla.childNodes:
+ # The issue elements contain the info for an issue
+ if issue.nodeType != issue.ELEMENT_NODE: continue
+ # Accumulate the pieces we want to include
+ d = {}
+ for element in issue.childNodes:
+ if element.nodeName in PickList:
+ d[element.nodeName] = Value(element)
+ # convert 'votes' to numeric, ascending and descending
+ try:
+ v = int('0' + d['votes'])
+ except KeyError:
+ pass
+ else:
+ d['votes_desc'] = -v
+ d['votes'] = v
+ # Marshal the elements and add them to the list
+ issues.append([ d[ix] for ix in PickList ])
issues.sort()
# Transcribe the issues into comma-separated values.
writer = csv.writer(open('editlist.csv', 'w'))
# header
writer.writerow(['ID', 'Votes', 'Type/Member', 'Milestone',
- 'Pri', 'Owner', 'Summary/Comments'])
+ 'Pri', 'Owner', 'Summary/Comments'])
for issue in issues:
- row = issue[4:] # strip off sort key
- #row[0] = """=hyperlink("http://scons.tigris.org/issues/show_bug.cgi?id=%s","%s")""" % (row[0],row[0])
- if row[3] == '-unspecified-': row[3] = 'triage'
- writer.writerow(['','','','','','',''])
- writer.writerow(row)
- writer.writerow(['','','consensus','','','',''])
- writer.writerow(['','','','','','',''])
- for member in team: writer.writerow(['','',member,'','','',''])
+ row = issue[4:] # strip off sort key
+ #row[0] = """=hyperlink("http://scons.tigris.org/issues/show_bug.cgi?id=%s","%s")""" % (row[0],row[0])
+ if row[3] == '-unspecified-': row[3] = 'triage'
+ writer.writerow(['','','','','','',''])
+ writer.writerow(row)
+ writer.writerow(['','','consensus','','','',''])
+ writer.writerow(['','','','','','',''])
+ for member in team: writer.writerow(['','',member,'','','',''])
# Local Variables:
# tab-width:4
def validate_color(key, val, env):
if not val in ['red', 'blue', 'yellow']:
- raise "Invalid color value '%s'" % val
+ raise Exception("Invalid color value '%s'" % val)
vars.Add('COLOR', validator=valid_color)
.EE
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)
_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):
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
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
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:
# 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)
# 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
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
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.
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:
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]
# 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):
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)
elif name == 'builder':
return self.method
else:
- raise AttributeError, name
+ raise AttributeError(name)
def __setattr__(self, name, value):
if name == 'env':
# 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):
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
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
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)
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
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
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):
"""
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:
def __str__(self):
return self.name
def __cmp__(self, other):
- raise "should not compare"
+ raise Exception("should not compare")
ccc = C('ccc')
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"
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
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)
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"""
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[:]
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"""
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):
# 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):
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:
}
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 = []
except (AttributeError, KeyError):
pass
if result:
- raise TypeError, errorfmt % node.abspath
+ raise TypeError(errorfmt % node.abspath)
def ignore_diskcheck_match(node, predicate, errorfmt):
pass
"""
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
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()
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):
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):
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:
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)
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)
#
#
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
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")
except TypeError:
pass
else:
- raise Exception, "did not catch expected TypeError"
+ raise Exception("did not catch expected TypeError")
assert x1.Entry(x4) == x4
try:
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)
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')
elif isinstance(curr_a, list):
all.extend(curr_a)
else:
- raise 'Cannot Combine Actions'
+ raise Exception('Cannot Combine Actions')
return MyListAction(all)
class MyActionBase:
class ExceptBuilder2:
def execute(self, target, source, env):
- raise "foo"
+ raise Exception("foo")
class Scanner:
called = None
except:
pass
else:
- raise "did not catch expected exception"
+ raise Exception("did not catch expected exception")
assert node.depends == [zero, one, two, three, four]
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):
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):
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):
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]
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):
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))
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:
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()
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.
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).
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'
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()
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()
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
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"
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__
# 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()
elif v in diskcheck_all:
result.append(v)
else:
- raise ValueError, v
+ raise ValueError(v)
return result
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:
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)
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
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]
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
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
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]
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
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 ]
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 ]
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:
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)
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):
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)
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)
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()
]
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"""
]
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"""
]
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):
]
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"""
]
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"""
]
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"""
" 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
"""
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)
"""
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)
# 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):
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
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
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
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 = []
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 = []
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)
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()
}
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:
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)
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
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')
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]+)')
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))
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:
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] )
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:
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):
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
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:
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):
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():
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')
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
# 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
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'):
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 \
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):
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
"""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."""
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']):
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):
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):
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):
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()
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()
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:
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']):
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()
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()
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']):
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']):
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:
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)]
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']):
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']):
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'):
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:
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,
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):
# 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]
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):
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"""
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:
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"""
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"""
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:
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"""
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',
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()")
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)
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:
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):
"""
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:
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()
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):
"""
parser.print_version()
parser.exit()
else:
- raise RuntimeError, "unknown action %r" % self.action
+ raise RuntimeError("unknown action %r" % self.action)
return 1
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)
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):
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)
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
"""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__
# 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,
# 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
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,
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
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 \
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
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
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"
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")
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")
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__"):
test.write('SConstruct', """
assert "InternalError" not in globals()
from SCons.Errors import InternalError
-raise InternalError, 'error inside'
+raise InternalError('error inside')
""")
test.run(stdout = "scons: Reading SConscript files ...\ninternal error\n",
File ".+", line \d+, in .+
File ".+", line \d+, in .+
File ".+SConstruct", line \d+, in .+
- raise InternalError, 'error inside'
+ raise InternalError\('error inside'\)
InternalError: error inside
""", status=2)
test.write('SConstruct', """
assert "UserError" not in globals()
import SCons.Errors
-raise SCons.Errors.UserError, 'Depends() requires both sources and targets.'
+raise SCons.Errors.UserError('Depends() requires both sources and targets.')
""")
expect = """
contents = node.get_text_contents()
exceptions = exception_re.findall(contents)
if exceptions:
- raise Exception, "kfile_scan error: %s" % exceptions[0]
+ raise Exception("kfile_scan error: %s" % exceptions[0])
includes = include_re.findall(contents)
return includes
except AttributeError:
pass
else:
- raise Exception, "unexpected variable SCons.Script.%s" % var
+ raise Exception("unexpected variable SCons.Script.%s" % var)
""")
test.write("m4.py", """\
try: env.subst('$NAME')
except SCons.Errors.UserError, e: print e
-else: raise Exception, "did not catch expected SCons.Errors.UserError"
+else: raise Exception("did not catch expected SCons.Errors.UserError")
try: env.subst('${NAME}')
except SCons.Errors.UserError, e: print e
-else: raise Exception, "did not catch expected SCons.Errors.UserError"
+else: raise Exception("did not catch expected SCons.Errors.UserError")
try: env.subst('${INDEX[999]}')
except SCons.Errors.UserError, e: print e
-else: raise Exception, "did not catch expected SCons.Errors.UserError"
+else: raise Exception("did not catch expected SCons.Errors.UserError")
try: env.subst_list('$NAME')
except SCons.Errors.UserError, e: print e
-else: raise Exception, "did not catch expected SCons.Errors.UserError"
+else: raise Exception("did not catch expected SCons.Errors.UserError")
try: env.subst_list('${NAME}')
except SCons.Errors.UserError, e: print e
-else: raise Exception, "did not catch expected SCons.Errors.UserError"
+else: raise Exception("did not catch expected SCons.Errors.UserError")
try: env.subst_list('${INDEX[999]}')
except SCons.Errors.UserError, e: print e
-else: raise Exception, "did not catch expected SCons.Errors.UserError"
+else: raise Exception("did not catch expected SCons.Errors.UserError")
try: env.subst('${1/0}')
except SCons.Errors.UserError, e: print e
-else: raise Exception, "did not catch expected SCons.Errors.UserError"
+else: raise Exception("did not catch expected SCons.Errors.UserError")
try: env.subst_list('${1/0}')
except SCons.Errors.UserError, e: print e
-else: raise Exception, "did not catch expected SCons.Errors.UserError"
+else: raise Exception("did not catch expected SCons.Errors.UserError")
AllowSubstExceptions(ZeroDivisionError)
test.write(SConstruct_path, """\
def func(source = None, target = None, env = None):
- raise Exception, "func exception"
+ raise Exception("func exception")
B = Builder(action = func)
env = Environment(BUILDERS = { 'B' : B })
env.B(target = 'foo.out', source = 'foo.in')
test.write('foo.in', "foo.in\n")
-expected_stderr = """scons: \*\*\* \[foo.out\] Exception : func exception
+expected_stderr = r"""scons: \*\*\* \[foo.out\] Exception : func exception
Traceback \((most recent call|innermost) last\):
( File ".+", line \d+, in \S+
[^\n]+
)*( File ".+", line \d+, in \S+
[^\n]+
)* File "%s", line 2, in func
- raise Exception, "func exception"
+ raise Exception\("func exception"\)
Exception: func exception
""" % re.escape(SConstruct_path)
test.write('SConstruct', """\
def kfile_scan(node, env, target):
- raise Exception, "kfile_scan error"
+ raise Exception("kfile_scan error")
kscan = Scanner(name = 'kfile',
function = kfile_scan,
lines = [
"scons: *** [foo] Exception : kfile_scan error",
"scons: internal stack trace:",
- 'raise Exception, "kfile_scan error"',
+ 'raise Exception("kfile_scan error")',
]
test.must_contain_all_lines(test.stderr(), lines)
test.write('SConstruct', """\
import SCons.Errors
-raise SCons.Errors.UserError, "explicit UserError!"
+raise SCons.Errors.UserError("explicit UserError!")
""")
test.run(arguments = '--debug=stacktrace',