Convert raise statements in Tools/.

This commit is contained in:
Collin Winter 2007-08-22 23:05:06 +00:00
parent 2d7f6a079d
commit a817e5894b
16 changed files with 29 additions and 29 deletions

View File

@ -40,7 +40,7 @@ class FixedInputOutputBufferType(InputOnlyType):
def getArgDeclarations(self, name, reference=False, constmode=False, outmode=False):
if reference:
raise RuntimeError, "Cannot pass buffer types by reference"
raise RuntimeError("Cannot pass buffer types by reference")
return (self.getBufferDeclarations(name, constmode, outmode) +
self.getSizeDeclarations(name, outmode))
@ -57,7 +57,7 @@ class FixedInputOutputBufferType(InputOnlyType):
def getOutputBufferDeclarations(self, name, constmode=False, outmode=False):
if constmode:
raise RuntimeError, "Cannot use const output buffer"
raise RuntimeError("Cannot use const output buffer")
if outmode:
out = "*"
else:
@ -216,7 +216,7 @@ class StructInputOutputBufferType(FixedInputOutputBufferType):
def getOutputBufferDeclarations(self, name, constmode=False, outmode=False):
if constmode:
raise RuntimeError, "Cannot use const output buffer"
raise RuntimeError("Cannot use const output buffer")
if outmode:
out = "*"
else:

View File

@ -280,7 +280,7 @@ class MethodGenerator(FunctionGenerator):
a0, args = args[0], args[1:]
t0, n0, m0 = a0
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.argumentList.append(self.itself)
FunctionGenerator.parseArgumentList(self, args)

View File

@ -18,7 +18,7 @@ class HeapInputOutputBufferType(FixedInputOutputBufferType):
def getOutputBufferDeclarations(self, name, constmode=False, outmode=False):
if constmode:
raise RuntimeError, "Cannot use const output buffer"
raise RuntimeError("Cannot use const output buffer")
if outmode:
out = "*"
else:

View File

@ -83,7 +83,7 @@ def IndentLevel(by = 1):
"""
global _Level
if _Level+by < 0:
raise Error, "indentation underflow (internal error)"
raise Error("indentation underflow (internal error)")
_Level = _Level + by
def DedentLevel(by = 1):

View File

@ -163,7 +163,7 @@ class InputOnlyMixIn:
"Mix-in class to boobytrap passOutput"
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):
@ -174,7 +174,7 @@ class OutputOnlyMixIn:
"Mix-in class to boobytrap passInput"
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):

View File

@ -420,7 +420,7 @@ if missing: raise "Missing Types"
try:
file = open(filename, 'w')
except IOError as arg:
raise IOError, (filename, arg)
raise IOError(filename, arg)
self.setfiletype(filename)
return file
@ -461,11 +461,11 @@ if missing: raise "Missing Types"
try:
return open(filename, 'rU')
except IOError as arg:
raise IOError, (arg, filename)
raise IOError(arg, filename)
def getline(self):
if not self.scanfile:
raise Error, "input file not set"
raise Error("input file not set")
self.line = self.scanfile.readline()
if not self.line:
if self._nextinput():

View File

@ -17,7 +17,7 @@ class Struct:
for _name, type in self.members:
if name == _name:
return type
raise ValueError, "no member named %s" % name
raise ValueError("no member named %s" % name)
def parse(s):
"""Parse a C struct definition.

View File

@ -39,7 +39,7 @@ def get_custom_entry_point(subsystem):
try:
return subsystem_details[subsystem][:2]
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):

View File

@ -63,8 +63,8 @@ class writer:
fn = os.path.join(fn, name)
if os.path.exists(fn):
return open(fn, 'r')
raise error, 'Template '+name+' not found for '+self._type+' '+ \
self.name
raise error('Template '+name+' not found for '+self._type+' '+ \
self.name)
class module(writer):
_type = 'module'

View File

@ -29,7 +29,7 @@ class Varsubst:
continue
name = m.group(1)
if not self.dict.has_key(name):
raise error, 'No such variable: '+name
raise error('No such variable: '+name)
value = self.dict[name]
if self.do_useindent and '\n' in value:
value = self._modindent(value, rv)

View File

@ -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)
msilib.set_arch_from_file(dll_path)
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:
ext = 'px'

View File

@ -254,7 +254,7 @@ def change_sequence(seq, action, seqno=_Unspecified, cond = _Unspecified):
seqno = seq[i][2]
seq[i] = (action, cond, seqno)
return
raise ValueError, "Action not found in sequence"
raise ValueError("Action not found in sequence")
def add_data(db, table, values):
d = MakeInstaller()
@ -274,7 +274,7 @@ def add_data(db, table, values):
elif isinstance(field, Binary):
r.SetStream(i+1, field.name)
else:
raise TypeError, "Unsupported type %s" % field.__class__.__name__
raise TypeError("Unsupported type %s" % field.__class__.__name__)
v.Modify(win32com.client.constants.msiViewModifyInsert, r)
r.ClearData()
v.Close()
@ -398,7 +398,7 @@ class CAB:
sys.stdout.write(line)
sys.stdout.flush()
if not os.path.exists(self.name+".cab"):
raise IOError, "cabarc failed"
raise IOError("cabarc failed")
add_data(db, "Media",
[(1, self.index, None, "#"+self.name, None, None)])
add_stream(db, self.name, self.name+".cab")
@ -672,5 +672,5 @@ def set_arch_from_file(path):
Win64 = 1
arch_ext = '.amd64'
else:
raise ValueError, "Unsupported architecture"
raise ValueError("Unsupported architecture")
msi_type += ";1033"

View File

@ -257,7 +257,7 @@ class TexinfoParser:
line = fp.readline()
lineno = lineno + 1
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)
# Parse the contents of a file, not expecting a MAGIC header
@ -475,7 +475,7 @@ class TexinfoParser:
continue
if c <> '@':
# Cannot happen unless spprog is changed
raise RuntimeError, 'unexpected funny %r' % c
raise RuntimeError('unexpected funny %r' % c)
start = i
while i < n and text[i] in string.ascii_letters: i = i+1
if i == start:

View File

@ -11,7 +11,7 @@ def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "t:")
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:
print(msg)
print("usage:", sys.argv[0], "[-t tabwidth] file ...")

View File

@ -138,7 +138,7 @@ def makeunicodedata(unicode, trace):
if record[5]:
decomp = record[5].split()
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
if decomp[0][0] == "<":
prefix = decomp.pop(0)
@ -608,7 +608,7 @@ def makeunicodename(unicode, trace):
def merge_old_version(version, new, old):
# Changes to exclusion file not implemented yet
if old.exclusions != new.exclusions:
raise NotImplementedError, "exclusions differ"
raise NotImplementedError("exclusions differ")
# In these change records, 0xFF means "no change"
bidir_changes = [0xFF]*0x110000
@ -677,7 +677,7 @@ def merge_old_version(version, new, old):
pass
else:
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,
decimal_changes, numeric_changes)),
normalization_changes))
@ -821,7 +821,7 @@ class Hash:
poly = size + poly
break
else:
raise AssertionError, "ran out of polynominals"
raise AssertionError("ran out of polynominals")
print(size, "slots in hash table")

View File

@ -1,7 +1,7 @@
import re, unicodedata, sys
if sys.maxunicode == 65535:
raise RuntimeError, "need UCS-4 Python"
raise RuntimeError("need UCS-4 Python")
def gen_category(cats):
for i in range(0, 0x110000):