]> granicus.if.org Git - python/commitdiff
Convert raise statements in Tools/.
authorCollin Winter <collinw@gmail.com>
Wed, 22 Aug 2007 23:05:06 +0000 (23:05 +0000)
committerCollin Winter <collinw@gmail.com>
Wed, 22 Aug 2007 23:05:06 +0000 (23:05 +0000)
16 files changed:
Tools/bgen/bgen/bgenBuffer.py
Tools/bgen/bgen/bgenGenerator.py
Tools/bgen/bgen/bgenHeapBuffer.py
Tools/bgen/bgen/bgenOutput.py
Tools/bgen/bgen/bgenType.py
Tools/bgen/bgen/scantools.py
Tools/framer/framer/struct.py
Tools/freeze/winmakemakefile.py
Tools/modulator/genmodule.py
Tools/modulator/varsubst.py
Tools/msi/msi.py
Tools/msi/msilib.py
Tools/scripts/texi2html.py
Tools/scripts/untabify.py
Tools/unicode/makeunicodedata.py
Tools/unicode/mkstringprep.py

index 94ab95003377db42ad53b71783127423445083cf..98bbfe2dce953fd20e4384c7985d58d2678a0f94 100644 (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:
index ae5c06bcfdd482cb53eadf30e8b226b84cff27e3..e364d01fc8a3f3f529b2422a887dcf8c9555f6a6 100644 (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)
index 930bb7e5fd1f06e7db5a80d6d59590ccfe3f956e..fda8d30133ed4baaa1db11d741f5d50574d0daef 100644 (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:
index 53d4f55f1c0f57765bfa32677a3a2a46e985033a..bceac59491429a93a1a7df8a156a83aebb4eb165 100644 (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):
index c988700cbff7a5e012849d621f3848cf3e5a5774..dcb0f086a40ea4d1feb23a393b827c48dd36697b 100644 (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):
 
index 3d973d0a892b4e06fcc68f535a28686d62f2c09b..d03bc93db63b1462879132fc941beb7f7ca8a7dc 100644 (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():
index 12ea8d7c48b7c5ad4ea98cad0b0cf278c6ebaa11..1289f24e01430a155272ee0aa1a1a652954ccddd 100644 (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.
index e473fed8417660539885c30eb4b826930b2f5614..7d198c152fafe7e9c4e78c23a5d4cc59c2a4e65c 100644 (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):
index da3068472d0dabb94e7df84f2c3d47b0dd6b0e91..7df398352a91823d372ed21bb363a3fe761f51ee 100755 (executable)
@@ -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'
index 3b33950650be7440380e1469450173c69c8fbc62..473fb55fb1a9e3d7fd16730dcc43e2f9c6c7627d 100644 (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)
index adf470f90a9cbbeecb8a7eb93055db31b7cd8725..a184973380d041600c6f2c712c6995a97f5d6435 100644 (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'
index 8aea216255cd92975ae74dfeda5b5012891fda3a..9823e2ab9e4cecbbb5d6466ee8b98995531136b2 100644 (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"
index 37d6e9168c731928599d5fbabf864681bd8d174b..eae466c021cce3cde05edaffb74b15a83993a73a 100755 (executable)
@@ -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:
index 49e9049bd3e252b750a69bec4be7e8a81298f676..1a186a32951368c4aa70cab7112dff0ac607ab95 100755 (executable)
@@ -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 ...")
index ab08887c24df84850a22fe8232807e01b24c56eb..3778efa6de564700fe07545ff24d5aea4c9b5f4c 100644 (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")
 
index b910d69fa69dc8b6d03566075a77c57b8c1d7faf..83a5d8fa144405d629746e729fee89e8434725e4 100644 (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):