Commit a817e589 authored by Collin Winter's avatar Collin Winter

Convert raise statements in Tools/.

parent 2d7f6a07
...@@ -40,7 +40,7 @@ class FixedInputOutputBufferType(InputOnlyType): ...@@ -40,7 +40,7 @@ class FixedInputOutputBufferType(InputOnlyType):
def getArgDeclarations(self, name, reference=False, constmode=False, outmode=False): def getArgDeclarations(self, name, reference=False, constmode=False, outmode=False):
if reference: if reference:
raise RuntimeError, "Cannot pass buffer types by reference" raise RuntimeError("Cannot pass buffer types by reference")
return (self.getBufferDeclarations(name, constmode, outmode) + return (self.getBufferDeclarations(name, constmode, outmode) +
self.getSizeDeclarations(name, outmode)) self.getSizeDeclarations(name, outmode))
...@@ -57,7 +57,7 @@ class FixedInputOutputBufferType(InputOnlyType): ...@@ -57,7 +57,7 @@ class FixedInputOutputBufferType(InputOnlyType):
def getOutputBufferDeclarations(self, name, constmode=False, outmode=False): def getOutputBufferDeclarations(self, name, constmode=False, outmode=False):
if constmode: if constmode:
raise RuntimeError, "Cannot use const output buffer" raise RuntimeError("Cannot use const output buffer")
if outmode: if outmode:
out = "*" out = "*"
else: else:
...@@ -216,7 +216,7 @@ class StructInputOutputBufferType(FixedInputOutputBufferType): ...@@ -216,7 +216,7 @@ class StructInputOutputBufferType(FixedInputOutputBufferType):
def getOutputBufferDeclarations(self, name, constmode=False, outmode=False): def getOutputBufferDeclarations(self, name, constmode=False, outmode=False):
if constmode: if constmode:
raise RuntimeError, "Cannot use const output buffer" raise RuntimeError("Cannot use const output buffer")
if outmode: if outmode:
out = "*" out = "*"
else: else:
......
...@@ -280,7 +280,7 @@ class MethodGenerator(FunctionGenerator): ...@@ -280,7 +280,7 @@ class MethodGenerator(FunctionGenerator):
a0, args = args[0], args[1:] a0, args = args[0], args[1:]
t0, n0, m0 = a0 t0, n0, m0 = a0
if m0 != InMode: if m0 != InMode:
raise ValueError, "method's 'self' must be 'InMode'" raise ValueError("method's 'self' must be 'InMode'")
self.itself = Variable(t0, "_self->ob_itself", SelfMode) self.itself = Variable(t0, "_self->ob_itself", SelfMode)
self.argumentList.append(self.itself) self.argumentList.append(self.itself)
FunctionGenerator.parseArgumentList(self, args) FunctionGenerator.parseArgumentList(self, args)
......
...@@ -18,7 +18,7 @@ class HeapInputOutputBufferType(FixedInputOutputBufferType): ...@@ -18,7 +18,7 @@ class HeapInputOutputBufferType(FixedInputOutputBufferType):
def getOutputBufferDeclarations(self, name, constmode=False, outmode=False): def getOutputBufferDeclarations(self, name, constmode=False, outmode=False):
if constmode: if constmode:
raise RuntimeError, "Cannot use const output buffer" raise RuntimeError("Cannot use const output buffer")
if outmode: if outmode:
out = "*" out = "*"
else: else:
......
...@@ -83,7 +83,7 @@ def IndentLevel(by = 1): ...@@ -83,7 +83,7 @@ def IndentLevel(by = 1):
""" """
global _Level global _Level
if _Level+by < 0: if _Level+by < 0:
raise Error, "indentation underflow (internal error)" raise Error("indentation underflow (internal error)")
_Level = _Level + by _Level = _Level + by
def DedentLevel(by = 1): def DedentLevel(by = 1):
......
...@@ -163,7 +163,7 @@ class InputOnlyMixIn: ...@@ -163,7 +163,7 @@ class InputOnlyMixIn:
"Mix-in class to boobytrap passOutput" "Mix-in class to boobytrap passOutput"
def passOutput(self, name): def passOutput(self, name):
raise RuntimeError, "Type '%s' can only be used for input parameters" % self.typeName raise RuntimeError("Type '%s' can only be used for input parameters" % self.typeName)
class InputOnlyType(InputOnlyMixIn, Type): class InputOnlyType(InputOnlyMixIn, Type):
...@@ -174,7 +174,7 @@ class OutputOnlyMixIn: ...@@ -174,7 +174,7 @@ class OutputOnlyMixIn:
"Mix-in class to boobytrap passInput" "Mix-in class to boobytrap passInput"
def passInput(self, name): def passInput(self, name):
raise RuntimeError, "Type '%s' can only be used for output parameters" % self.typeName raise RuntimeError("Type '%s' can only be used for output parameters" % self.typeName)
class OutputOnlyType(OutputOnlyMixIn, Type): class OutputOnlyType(OutputOnlyMixIn, Type):
......
...@@ -420,7 +420,7 @@ if missing: raise "Missing Types" ...@@ -420,7 +420,7 @@ if missing: raise "Missing Types"
try: try:
file = open(filename, 'w') file = open(filename, 'w')
except IOError as arg: except IOError as arg:
raise IOError, (filename, arg) raise IOError(filename, arg)
self.setfiletype(filename) self.setfiletype(filename)
return file return file
...@@ -461,11 +461,11 @@ if missing: raise "Missing Types" ...@@ -461,11 +461,11 @@ if missing: raise "Missing Types"
try: try:
return open(filename, 'rU') return open(filename, 'rU')
except IOError as arg: except IOError as arg:
raise IOError, (arg, filename) raise IOError(arg, filename)
def getline(self): def getline(self):
if not self.scanfile: if not self.scanfile:
raise Error, "input file not set" raise Error("input file not set")
self.line = self.scanfile.readline() self.line = self.scanfile.readline()
if not self.line: if not self.line:
if self._nextinput(): if self._nextinput():
......
...@@ -17,7 +17,7 @@ class Struct: ...@@ -17,7 +17,7 @@ class Struct:
for _name, type in self.members: for _name, type in self.members:
if name == _name: if name == _name:
return type return type
raise ValueError, "no member named %s" % name raise ValueError("no member named %s" % name)
def parse(s): def parse(s):
"""Parse a C struct definition. """Parse a C struct definition.
......
...@@ -39,7 +39,7 @@ def get_custom_entry_point(subsystem): ...@@ -39,7 +39,7 @@ def get_custom_entry_point(subsystem):
try: try:
return subsystem_details[subsystem][:2] return subsystem_details[subsystem][:2]
except KeyError: except KeyError:
raise ValueError, "The subsystem %s is not known" % subsystem raise ValueError("The subsystem %s is not known" % subsystem)
def makemakefile(outfp, vars, files, target): def makemakefile(outfp, vars, files, target):
......
...@@ -63,8 +63,8 @@ class writer: ...@@ -63,8 +63,8 @@ class writer:
fn = os.path.join(fn, name) fn = os.path.join(fn, name)
if os.path.exists(fn): if os.path.exists(fn):
return open(fn, 'r') return open(fn, 'r')
raise error, 'Template '+name+' not found for '+self._type+' '+ \ raise error('Template '+name+' not found for '+self._type+' '+ \
self.name self.name)
class module(writer): class module(writer):
_type = 'module' _type = 'module'
......
...@@ -29,7 +29,7 @@ class Varsubst: ...@@ -29,7 +29,7 @@ class Varsubst:
continue continue
name = m.group(1) name = m.group(1)
if not self.dict.has_key(name): if not self.dict.has_key(name):
raise error, 'No such variable: '+name raise error('No such variable: '+name)
value = self.dict[name] value = self.dict[name]
if self.do_useindent and '\n' in value: if self.do_useindent and '\n' in value:
value = self._modindent(value, rv) value = self._modindent(value, rv)
......
...@@ -157,7 +157,7 @@ have_mingw = build_mingw_lib(lib_file, def_file, dll_file, mingw_lib) ...@@ -157,7 +157,7 @@ have_mingw = build_mingw_lib(lib_file, def_file, dll_file, mingw_lib)
dll_path = os.path.join(srcdir, "PCBuild", dll_file) dll_path = os.path.join(srcdir, "PCBuild", dll_file)
msilib.set_arch_from_file(dll_path) msilib.set_arch_from_file(dll_path)
if msilib.pe_type(dll_path) != msilib.pe_type("msisupport.dll"): if msilib.pe_type(dll_path) != msilib.pe_type("msisupport.dll"):
raise SystemError, "msisupport.dll for incorrect architecture" raise SystemError("msisupport.dll for incorrect architecture")
if testpackage: if testpackage:
ext = 'px' ext = 'px'
......
...@@ -254,7 +254,7 @@ def change_sequence(seq, action, seqno=_Unspecified, cond = _Unspecified): ...@@ -254,7 +254,7 @@ def change_sequence(seq, action, seqno=_Unspecified, cond = _Unspecified):
seqno = seq[i][2] seqno = seq[i][2]
seq[i] = (action, cond, seqno) seq[i] = (action, cond, seqno)
return return
raise ValueError, "Action not found in sequence" raise ValueError("Action not found in sequence")
def add_data(db, table, values): def add_data(db, table, values):
d = MakeInstaller() d = MakeInstaller()
...@@ -274,7 +274,7 @@ def add_data(db, table, values): ...@@ -274,7 +274,7 @@ def add_data(db, table, values):
elif isinstance(field, Binary): elif isinstance(field, Binary):
r.SetStream(i+1, field.name) r.SetStream(i+1, field.name)
else: else:
raise TypeError, "Unsupported type %s" % field.__class__.__name__ raise TypeError("Unsupported type %s" % field.__class__.__name__)
v.Modify(win32com.client.constants.msiViewModifyInsert, r) v.Modify(win32com.client.constants.msiViewModifyInsert, r)
r.ClearData() r.ClearData()
v.Close() v.Close()
...@@ -398,7 +398,7 @@ class CAB: ...@@ -398,7 +398,7 @@ class CAB:
sys.stdout.write(line) sys.stdout.write(line)
sys.stdout.flush() sys.stdout.flush()
if not os.path.exists(self.name+".cab"): if not os.path.exists(self.name+".cab"):
raise IOError, "cabarc failed" raise IOError("cabarc failed")
add_data(db, "Media", add_data(db, "Media",
[(1, self.index, None, "#"+self.name, None, None)]) [(1, self.index, None, "#"+self.name, None, None)])
add_stream(db, self.name, self.name+".cab") add_stream(db, self.name, self.name+".cab")
...@@ -672,5 +672,5 @@ def set_arch_from_file(path): ...@@ -672,5 +672,5 @@ def set_arch_from_file(path):
Win64 = 1 Win64 = 1
arch_ext = '.amd64' arch_ext = '.amd64'
else: else:
raise ValueError, "Unsupported architecture" raise ValueError("Unsupported architecture")
msi_type += ";1033" msi_type += ";1033"
...@@ -257,7 +257,7 @@ class TexinfoParser: ...@@ -257,7 +257,7 @@ class TexinfoParser:
line = fp.readline() line = fp.readline()
lineno = lineno + 1 lineno = lineno + 1
if line[:len(MAGIC)] <> MAGIC: if line[:len(MAGIC)] <> MAGIC:
raise SyntaxError, 'file does not begin with %r' % (MAGIC,) raise SyntaxError('file does not begin with %r' % (MAGIC,))
self.parserest(fp, lineno) self.parserest(fp, lineno)
# Parse the contents of a file, not expecting a MAGIC header # Parse the contents of a file, not expecting a MAGIC header
...@@ -475,7 +475,7 @@ class TexinfoParser: ...@@ -475,7 +475,7 @@ class TexinfoParser:
continue continue
if c <> '@': if c <> '@':
# Cannot happen unless spprog is changed # Cannot happen unless spprog is changed
raise RuntimeError, 'unexpected funny %r' % c raise RuntimeError('unexpected funny %r' % c)
start = i start = i
while i < n and text[i] in string.ascii_letters: i = i+1 while i < n and text[i] in string.ascii_letters: i = i+1
if i == start: if i == start:
......
...@@ -11,7 +11,7 @@ def main(): ...@@ -11,7 +11,7 @@ def main():
try: try:
opts, args = getopt.getopt(sys.argv[1:], "t:") opts, args = getopt.getopt(sys.argv[1:], "t:")
if not args: if not args:
raise getopt.error, "At least one file argument required" raise getopt.error("At least one file argument required")
except getopt.error as msg: except getopt.error as msg:
print(msg) print(msg)
print("usage:", sys.argv[0], "[-t tabwidth] file ...") print("usage:", sys.argv[0], "[-t tabwidth] file ...")
......
...@@ -138,7 +138,7 @@ def makeunicodedata(unicode, trace): ...@@ -138,7 +138,7 @@ def makeunicodedata(unicode, trace):
if record[5]: if record[5]:
decomp = record[5].split() decomp = record[5].split()
if len(decomp) > 19: if len(decomp) > 19:
raise Exception, "character %x has a decomposition too large for nfd_nfkd" % char raise Exception("character %x has a decomposition too large for nfd_nfkd" % char)
# prefix # prefix
if decomp[0][0] == "<": if decomp[0][0] == "<":
prefix = decomp.pop(0) prefix = decomp.pop(0)
...@@ -608,7 +608,7 @@ def makeunicodename(unicode, trace): ...@@ -608,7 +608,7 @@ def makeunicodename(unicode, trace):
def merge_old_version(version, new, old): def merge_old_version(version, new, old):
# Changes to exclusion file not implemented yet # Changes to exclusion file not implemented yet
if old.exclusions != new.exclusions: if old.exclusions != new.exclusions:
raise NotImplementedError, "exclusions differ" raise NotImplementedError("exclusions differ")
# In these change records, 0xFF means "no change" # In these change records, 0xFF means "no change"
bidir_changes = [0xFF]*0x110000 bidir_changes = [0xFF]*0x110000
...@@ -677,7 +677,7 @@ def merge_old_version(version, new, old): ...@@ -677,7 +677,7 @@ def merge_old_version(version, new, old):
pass pass
else: else:
class Difference(Exception):pass class Difference(Exception):pass
raise Difference, (hex(i), k, old.table[i], new.table[i]) raise Difference(hex(i), k, old.table[i], new.table[i])
new.changed.append((version, list(zip(bidir_changes, category_changes, new.changed.append((version, list(zip(bidir_changes, category_changes,
decimal_changes, numeric_changes)), decimal_changes, numeric_changes)),
normalization_changes)) normalization_changes))
...@@ -821,7 +821,7 @@ class Hash: ...@@ -821,7 +821,7 @@ class Hash:
poly = size + poly poly = size + poly
break break
else: else:
raise AssertionError, "ran out of polynominals" raise AssertionError("ran out of polynominals")
print(size, "slots in hash table") print(size, "slots in hash table")
......
import re, unicodedata, sys import re, unicodedata, sys
if sys.maxunicode == 65535: if sys.maxunicode == 65535:
raise RuntimeError, "need UCS-4 Python" raise RuntimeError("need UCS-4 Python")
def gen_category(cats): def gen_category(cats):
for i in range(0, 0x110000): for i in range(0, 0x110000):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment