From: gregnoel Date: Thu, 15 Apr 2010 00:02:59 +0000 (+0000) Subject: http://scons.tigris.org/issues/show_bug.cgi?id=2345 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6a218d30e5fa1a14835a31129881b4288db7dc1d;p=scons.git 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). git-svn-id: http://scons.tigris.org/svn/scons/trunk@4785 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index 0139b297..6f538928 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -438,7 +438,7 @@ def match_re(lines = None, res = None): 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 @@ -455,7 +455,7 @@ def match_re_dotall(lines = None, res = None): 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 @@ -511,7 +511,7 @@ def diff_re(a, b, fromfile='', tofile='', 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])) @@ -1128,7 +1128,7 @@ class TestCmd(object): """ 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): @@ -1586,7 +1586,7 @@ class TestCmd(object): """ 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: diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index b7e019d5..d61c0089 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -813,7 +813,7 @@ SConscript( sconscript ) 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) @@ -888,7 +888,7 @@ SConscript( sconscript ) 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." diff --git a/QMTest/unittest.py b/QMTest/unittest.py index 476c1fc1..1d87c152 100644 --- a/QMTest/unittest.py +++ b/QMTest/unittest.py @@ -124,8 +124,8 @@ class TestCase: 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." @@ -199,7 +199,7 @@ class TestCase: __debug__ is false. """ if not expr: - raise AssertionError, msg + raise AssertionError(msg) failUnless = assert_ @@ -222,11 +222,11 @@ class TestCase: 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 @@ -376,7 +376,7 @@ def createTestInstance(name, module=None): """ 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 @@ -385,7 +385,7 @@ def createTestInstance(name, module=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: @@ -393,20 +393,19 @@ def createTestInstance(name, module=None): 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 @@ -662,7 +661,7 @@ Examples: 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: diff --git a/bench/dependency-func.py b/bench/dependency-func.py index beaa6266..7313cf97 100644 --- a/bench/dependency-func.py +++ b/bench/dependency-func.py @@ -26,7 +26,7 @@ def use_if_tests(env, dep, arg): elif t == '4444': func = dep.func4 else: - raise Exception, "bad key %s" % t + raise Exception("bad key %s" % t) return func(arg) diff --git a/bench/env.__setitem__.py b/bench/env.__setitem__.py index 36a76727..831a5071 100644 --- a/bench/env.__setitem__.py +++ b/bench/env.__setitem__.py @@ -115,7 +115,7 @@ class env_Original(Environment): 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): @@ -126,7 +126,7 @@ 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): @@ -143,7 +143,7 @@ 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): @@ -154,7 +154,7 @@ 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): @@ -165,7 +165,7 @@ 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): @@ -175,7 +175,7 @@ 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): @@ -185,7 +185,7 @@ 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): @@ -195,7 +195,7 @@ 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): @@ -205,7 +205,7 @@ 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): @@ -219,7 +219,7 @@ 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): @@ -231,7 +231,7 @@ 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): @@ -242,7 +242,7 @@ 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): @@ -253,7 +253,7 @@ 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): @@ -264,7 +264,7 @@ 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: @@ -279,7 +279,7 @@ else: 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 diff --git a/bin/xmlagenda.py b/bin/xmlagenda.py index fb62f9a2..79373310 100755 --- a/bin/xmlagenda.py +++ b/bin/xmlagenda.py @@ -21,19 +21,19 @@ team = sorted('Steven Gary Greg Ken Jim David Bill Sergey Jason'.split()) # 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 @@ -46,26 +46,26 @@ xml = parse(xml) # 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. @@ -74,16 +74,16 @@ import csv 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 diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 9c5e5de1..3a47547e 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -7393,7 +7393,7 @@ vars.Add('CC', 'The C compiler') 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 diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index ff67b490..6b046126 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 4cb5a0ab..4ffbdecf 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 4cce92f9..bbf503c0 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 38eb0cac..50cf7788 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 d585888a..3ccfe7f8 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 f532354d..cc2e0a00 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 5449669e..cd637bb2 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 0719853b..9f0e167e 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 1eee6e1b..9c8b925f 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 8f9b917d..feedf579 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 aaafa070..8e067426 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 85708ad1..6e39d4bc 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 4566d31b..30e7d9fa 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 acba76ea..6dd5b0b7 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 01ceb511..8ced5488 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 5f1b4b09..6de6d386 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 472f99f0..d635933e 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 2ae1e972..244d0900 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 ac019ad3..387312b2 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 4d29b789..2b2380da 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 7ae584ae..c7f560e9 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 b75da580..9ebe2e67 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 096fc9fa..54b23730 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 7909b0bb..96fc4b74 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 0f364d6a..246d4eb3 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 4e433829..7640ec85 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 a0a48597..caddd757 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 b423fa4e..0334f14a 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 1b42bcb2..f60b2e25 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 917bb622..3dd22e3e 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 1dfeefb9..f2f71907 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 dc07192e..75de6ec3 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 4baa9fd8..b8aae842 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 264166f6..6994bc6f 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 dc124b50..9f925b9c 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 b22fb59f..e068bf5f 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 abdd4797..dde0c98d 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 1cc13127..fffda70b 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/ 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 8d40a0bc..98156dd2 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 b1ba1df0..e0eec8c2 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 fde93ea8..41e793aa 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 69864885..304c35ea 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 e84b8127..e762d559 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 b80f1281..462228f7 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 6816af07..d61db37e 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 e0440653..15ee2a6f 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 16432522..084154bd 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 09d4e29a..171c0980 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 1792dc48..a68ef72e 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 66a32553..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 9c3df525..db6fd0d2 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 765867b0..211ff161 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 dfca2c1d..6ed39cfa 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 5e159eca..80b1c8bd 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 8e40a5f0..5acd0f27 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 ", 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 ", 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__"): diff --git a/test/Errors/InternalError.py b/test/Errors/InternalError.py index 49d9fdd8..8ed6da14 100644 --- a/test/Errors/InternalError.py +++ b/test/Errors/InternalError.py @@ -37,7 +37,7 @@ test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) 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", @@ -46,7 +46,7 @@ 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) diff --git a/test/Errors/UserError.py b/test/Errors/UserError.py index 0212a528..669260d5 100644 --- a/test/Errors/UserError.py +++ b/test/Errors/UserError.py @@ -36,7 +36,7 @@ test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) 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 = """ diff --git a/test/Scanner/exception.py b/test/Scanner/exception.py index 1e229315..5af7ac3c 100644 --- a/test/Scanner/exception.py +++ b/test/Scanner/exception.py @@ -47,7 +47,7 @@ def kfile_scan(node, env, target, arg): 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 diff --git a/test/Script-import.py b/test/Script-import.py index 2e1b6092..98ae2714 100644 --- a/test/Script-import.py +++ b/test/Script-import.py @@ -86,7 +86,7 @@ for var in old_SCons_Script_variables: except AttributeError: pass else: - raise Exception, "unexpected variable SCons.Script.%s" % var + raise Exception("unexpected variable SCons.Script.%s" % var) """) test.write("m4.py", """\ diff --git a/test/Subst/AllowSubstExceptions.py b/test/Subst/AllowSubstExceptions.py index 6401f7e7..c49f62f4 100644 --- a/test/Subst/AllowSubstExceptions.py +++ b/test/Subst/AllowSubstExceptions.py @@ -49,37 +49,37 @@ AllowSubstExceptions() 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) diff --git a/test/exceptions.py b/test/exceptions.py index 6a68c79a..79d869c4 100644 --- a/test/exceptions.py +++ b/test/exceptions.py @@ -36,7 +36,7 @@ SConstruct_path = test.workpath('SConstruct') 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') @@ -44,7 +44,7 @@ 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]+ @@ -52,7 +52,7 @@ Traceback \((most recent call|innermost) last\): )*( 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) diff --git a/test/option/debug-stacktrace.py b/test/option/debug-stacktrace.py index b29b39d0..fcc4c1bd 100644 --- a/test/option/debug-stacktrace.py +++ b/test/option/debug-stacktrace.py @@ -34,7 +34,7 @@ test = TestSCons.TestSCons() 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, @@ -57,7 +57,7 @@ test.run(arguments = "--debug=stacktrace", 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) @@ -69,7 +69,7 @@ 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',