[Scipy-svn] r6935 - in trunk/scipy/weave: . tests

scipy-svn@scip... scipy-svn@scip...
Sat Nov 20 12:42:42 CST 2010


Author: warren.weckesser
Date: 2010-11-20 12:42:42 -0600 (Sat, 20 Nov 2010)
New Revision: 6935

Modified:
   trunk/scipy/weave/accelerate_tools.py
   trunk/scipy/weave/base_spec.py
   trunk/scipy/weave/blitz_spec.py
   trunk/scipy/weave/build_tools.py
   trunk/scipy/weave/bytecodecompiler.py
   trunk/scipy/weave/catalog.py
   trunk/scipy/weave/ext_tools.py
   trunk/scipy/weave/inline_tools.py
   trunk/scipy/weave/platform_info.py
   trunk/scipy/weave/size_check.py
   trunk/scipy/weave/swig2_spec.py
   trunk/scipy/weave/tests/test_size_check.py
   trunk/scipy/weave/tests/weave_test_utils.py
Log:
ENH: weave: update 'raise' statements.

Modified: trunk/scipy/weave/accelerate_tools.py
===================================================================
--- trunk/scipy/weave/accelerate_tools.py	2010-11-20 18:19:28 UTC (rev 6934)
+++ trunk/scipy/weave/accelerate_tools.py	2010-11-20 18:42:42 UTC (rev 6935)
@@ -265,7 +265,7 @@
         elif issubclass(T, InstanceType):
             return Instance(x)
         else:
-            raise NotImplementedError,T
+            raise NotImplementedError(T)
 
 ##################################################################
 #                        class ACCELERATE                        #
@@ -332,7 +332,7 @@
         weave.build_tools.build_extension(self.module.__name__+'_weave.cpp',verbose=2)
 
         if accelerated_module:
-            raise NotImplementedError,'Reload'
+            raise NotImplementedError('Reload')
         else:
             accelerated_module = __import__(self.module.__name__+'_weave')
 
@@ -356,10 +356,10 @@
 
     def code(self,*args):
         if len(args) != self.function.func_code.co_argcount:
-            raise TypeError,'%s() takes exactly %d arguments (%d given)'%(
-                self.function.__name__,
-                self.function.func_code.co_argcount,
-                len(args))
+            raise TypeError('%s() takes exactly %d arguments (%d given)' %
+                        (self.function.__name__,
+                         self.function.func_code.co_argcount,
+                         len(args)))
         signature = tuple( map(lookup_type,args) )
         ident = self.function.__name__
         return self.accelerate(signature,ident).function_code()

Modified: trunk/scipy/weave/base_spec.py
===================================================================
--- trunk/scipy/weave/base_spec.py	2010-11-20 18:19:28 UTC (rev 6934)
+++ trunk/scipy/weave/base_spec.py	2010-11-20 18:42:42 UTC (rev 6935)
@@ -30,7 +30,7 @@
     def set_compiler(self,compiler):
         self.compiler = compiler
     def type_match(self,value):
-        raise NotImplementedError, "You must override method in derived class"
+        raise NotImplementedError("You must override method in derived class")
     def build_information(self):
         return self._build_information
     def type_spec(self,name,value):

Modified: trunk/scipy/weave/blitz_spec.py
===================================================================
--- trunk/scipy/weave/blitz_spec.py	2010-11-20 18:19:28 UTC (rev 6934)
+++ trunk/scipy/weave/blitz_spec.py	2010-11-20 18:42:42 UTC (rev 6935)
@@ -101,7 +101,7 @@
         if new_spec.dims > 11:
             msg = "Error converting variable '" + name + "'.  " \
                   "blitz only supports arrays up to 11 dimensions."
-            raise ValueError, msg
+            raise ValueError(msg)
         return new_spec
 
     def template_vars(self,inline=0):

Modified: trunk/scipy/weave/build_tools.py
===================================================================
--- trunk/scipy/weave/build_tools.py	2010-11-20 18:19:28 UTC (rev 6934)
+++ trunk/scipy/weave/build_tools.py	2010-11-20 18:42:42 UTC (rev 6935)
@@ -407,7 +407,7 @@
     if not os.access(temp_dir,os.W_OK):
         msg = "Either the temp or build directory wasn't writable. Check" \
               " these locations: '%s'" % temp_dir
-        raise ValueError, msg
+        raise ValueError(msg)
     return temp_dir
 
 def configure_build_dir(build_dir=None):
@@ -434,7 +434,7 @@
     if not os.access(build_dir,os.W_OK):
         msg = "The build directory wasn't writable. Check" \
               " this location: '%s'" % build_dir
-        raise ValueError, msg
+        raise ValueError(msg)
 
     return os.path.abspath(build_dir)
 

Modified: trunk/scipy/weave/bytecodecompiler.py
===================================================================
--- trunk/scipy/weave/bytecodecompiler.py	2010-11-20 18:19:28 UTC (rev 6934)
+++ trunk/scipy/weave/bytecodecompiler.py	2010-11-20 18:42:42 UTC (rev 6935)
@@ -987,7 +987,7 @@
             if module and id(module.__dict__) == myHash:
                 break
         else:
-            raise ValueError,'Cannot locate module owning %s'%var_name
+            raise ValueError('Cannot locate module owning %s' % var_name)
         return module_name,var_name
 
 
@@ -1157,7 +1157,7 @@
         for VV,TT in map(None, self.stack, self.types):
             print VV,':',TT
         if t is None:
-            raise TypeError,'%s used before set?'%v
+            raise TypeError('%s used before set?' % v)
             print self.__body
             print 'PC',pc
         self.push(v,t)
@@ -1288,7 +1288,7 @@
             self.types[var_num] = t
             return
 
-        raise TypeError,(t,saveT)
+        raise TypeError((t,saveT))
 
     ##################################################################
     #                      MEMBER STORE_GLOBAL                       #
@@ -1364,7 +1364,7 @@
             )
         self.post(pc+delta,action)
         if not isinstance(t, int):
-            raise TypeError, 'Invalid comparison type %s'%t
+            raise TypeError('Invalid comparison type %s' % t)
         self.emit('if (%s) {\n'%v)
 
 
@@ -1386,7 +1386,7 @@
         if hasattr(self,'rtype'):
             if t is None:
                 return # just the extra return
-            raise ValueError,'multiple returns: (v=%s, t=%s)' % (v, t)
+            raise ValueError('multiple returns: (v=%s, t=%s)' % (v, t))
         self.rtype = t
         if t is None:
             self.emit('return;')

Modified: trunk/scipy/weave/catalog.py
===================================================================
--- trunk/scipy/weave/catalog.py	2010-11-20 18:19:28 UTC (rev 6934)
+++ trunk/scipy/weave/catalog.py	2010-11-20 18:42:42 UTC (rev 6935)
@@ -295,7 +295,7 @@
     """
     if mode not in ['c','r','w','n']:
         msg = " mode must be 'c', 'n', 'r', or 'w'.  See anydbm for more info"
-        raise ValueError, msg
+        raise ValueError(msg)
     catalog_file = catalog_path(module_path)
     if (catalog_file is not None) \
            and ((dumb and os.path.exists(catalog_file+'.dat')) \
@@ -680,7 +680,7 @@
                 os.remove(f)
             cat = get_catalog(cat_dir,mode)
         if cat is None:
-            raise ValueError, 'Failed to access a catalog for storing functions'
+            raise ValueError('Failed to access a catalog for storing functions')
         # Prabhu was getting some corrupt catalog errors.  I'll put a try/except
         # to protect against this, but should really try and track down the issue.
         function_list = [function]

Modified: trunk/scipy/weave/ext_tools.py
===================================================================
--- trunk/scipy/weave/ext_tools.py	2010-11-20 18:19:28 UTC (rev 6934)
+++ trunk/scipy/weave/ext_tools.py	2010-11-20 18:42:42 UTC (rev 6935)
@@ -366,7 +366,7 @@
                                               compiler_name = compiler,
                                               verbose = verbose, **kw)
         if not success:
-            raise SystemError, 'Compilation failed'
+            raise SystemError('Compilation failed')
 
 def generate_file_name(module_name,module_location):
     module_file = os.path.join(module_location,module_name)
@@ -420,7 +420,7 @@
             errors[var] = ("Unable to convert variable '"+ var +
                            "' to a C++ type.")
     if errors:
-        raise TypeError, format_error_msg(errors)
+        raise TypeError(format_error_msg(errors))
 
     if auto_downcast:
         variable_specs = downcast(variable_specs)

Modified: trunk/scipy/weave/inline_tools.py
===================================================================
--- trunk/scipy/weave/inline_tools.py	2010-11-20 18:19:28 UTC (rev 6934)
+++ trunk/scipy/weave/inline_tools.py	2010-11-20 18:42:42 UTC (rev 6935)
@@ -327,13 +327,13 @@
             if msg[:16] == "Conversion Error":
                 pass
             else:
-                raise TypeError, msg
+                raise TypeError(msg)
         except NameError, msg:
             msg = str(msg).strip()
             if msg[:16] == "Conversion Error":
                 pass
             else:
-                raise NameError, msg
+                raise NameError(msg)
         except KeyError:
             pass
         # 2. try function catalog
@@ -372,13 +372,13 @@
         if msg[:16] == "Conversion Error":
             pass
         else:
-            raise TypeError, msg
+            raise TypeError(msg)
     except NameError, msg:
         msg = str(msg).strip()
         if msg[:16] == "Conversion Error":
             pass
         else:
-            raise NameError, msg
+            raise NameError(msg)
     except KeyError:
         pass
     # 2. try catalog cache.
@@ -397,13 +397,13 @@
             if msg[:16] == "Conversion Error":
                 pass
             else:
-                raise TypeError, msg
+                raise TypeError(msg)
         except NameError, msg:
             msg = str(msg).strip()
             if msg[:16] == "Conversion Error":
                 pass
             else:
-                raise NameError, msg
+                raise NameError(msg)
     # 3. try persistent catalog
     module_dir = global_dict.get('__file__',None)
     function_list = function_catalog.get_functions(code,module_dir)
@@ -416,7 +416,7 @@
         except: # should specify argument types here.
             pass
     # if we get here, the function wasn't found
-    raise ValueError, 'function with correct signature not found'
+    raise ValueError('function with correct signature not found')
 
 def inline_function_code(code,arg_names,local_dict=None,
                          global_dict=None,auto_downcast = 1,

Modified: trunk/scipy/weave/platform_info.py
===================================================================
--- trunk/scipy/weave/platform_info.py	2010-11-20 18:19:28 UTC (rev 6934)
+++ trunk/scipy/weave/platform_info.py	2010-11-20 18:42:42 UTC (rev 6935)
@@ -113,7 +113,7 @@
     exe_name = compiler_exe_name(compiler_obj)
     exe_path = compiler_exe_path(exe_name)
     if not exe_path:
-        raise ValueError, "The '%s' compiler was not found." % compiler_name
+        raise ValueError("The '%s' compiler was not found." % compiler_name)
     chk_sum = check_sum(exe_path)
     restore_sys_argv()
 

Modified: trunk/scipy/weave/size_check.py
===================================================================
--- trunk/scipy/weave/size_check.py	2010-11-20 18:19:28 UTC (rev 6934)
+++ trunk/scipy/weave/size_check.py	2010-11-20 18:42:42 UTC (rev 6935)
@@ -98,7 +98,7 @@
             res[i] = x[i]
         else:
             # offer more information here about which variables.
-            raise ValueError, "frames are not aligned"
+            raise ValueError("frames are not aligned")
     return res
 
 class dummy_array(object):
@@ -170,14 +170,14 @@
         if not isinstance(indices, tuple):
             indices = (indices,)
         if Ellipsis in indices:
-            raise IndexError, "Ellipsis not currently supported"
+            raise IndexError("Ellipsis not currently supported")
         new_dims = []
         dim = 0
         for index in indices:
             try:
                 dim_len = self.shape[dim]
             except IndexError:
-                raise IndexError, "To many indices specified"
+                raise IndexError("To many indices specified")
 
             #if (type(index) is SliceType and index.start == index.stop == index.step):
             if (index is empty_slice):
@@ -237,11 +237,11 @@
                     #this reduces the array dimensions by one
                     pass
                 else:
-                    raise IndexError, "Index out of range"
+                    raise IndexError("Index out of range")
             dim += 1
         new_dims.extend(self.shape[dim:])
         if 0 in new_dims:
-            raise IndexError, "Zero length slices not currently supported"
+            raise IndexError("Zero length slices not currently supported")
         return dummy_array(new_dims,1)
     def __repr__(self):
         val = str((self.name, str(self.shape)))
@@ -269,7 +269,7 @@
     if axis < 0:
         axis += len(ary.shape)
     if axis < 0 or axis >= len(ary.shape):
-        raise ValueError, "Dimension not in array"
+        raise ValueError("Dimension not in array")
     new_dims = list(ary.shape[:axis]) + list(ary.shape[axis+1:])
     return dummy_array(new_dims,1)
 

Modified: trunk/scipy/weave/swig2_spec.py
===================================================================
--- trunk/scipy/weave/swig2_spec.py	2010-11-20 18:19:28 UTC (rev 6934)
+++ trunk/scipy/weave/swig2_spec.py	2010-11-20 18:42:42 UTC (rev 6935)
@@ -266,7 +266,7 @@
         elif rv == 3:
             self.support_code.append(swigptr2.swigptr2_code_v3)
         else:
-            raise AssertionError, "Unsupported version of the SWIG runtime:", rv
+            raise AssertionError("Unsupported version of the SWIG runtime: %s" % rv)
 
         self.support_code.append(swig2_common_code)
 
@@ -339,7 +339,7 @@
         elif swig_ob_type == 'pyswig':
             pycobj = 2
         else:
-            raise AssertionError, "Does not look like a SWIG object: %s"%value
+            raise AssertionError("Does not look like a SWIG object: %s" % value)
 
         if pycobj:
             class_name = value.__class__.__name__

Modified: trunk/scipy/weave/tests/test_size_check.py
===================================================================
--- trunk/scipy/weave/tests/test_size_check.py	2010-11-20 18:19:28 UTC (rev 6934)
+++ trunk/scipy/weave/tests/test_size_check.py	2010-11-20 18:42:42 UTC (rev 6935)
@@ -124,7 +124,7 @@
             if 0 not in desired:
                 msg = '%s raised IndexError in dummy_array, but forms\n' \
                       'valid array shape -> %s' % (expr, str(desired))
-                raise AttributeError, msg
+                raise AttributeError(msg)
     def generic_1d(self,expr):
         a = np.arange(10)
         self.generic_wrap(a,expr)

Modified: trunk/scipy/weave/tests/weave_test_utils.py
===================================================================
--- trunk/scipy/weave/tests/weave_test_utils.py	2010-11-20 18:19:28 UTC (rev 6934)
+++ trunk/scipy/weave/tests/weave_test_utils.py	2010-11-20 18:42:42 UTC (rev 6935)
@@ -108,20 +108,17 @@
         return dst
 
     if not isfile(src):
-        raise DistutilsFileError, \
-              "can't move '%s': not a regular file" % src
+        raise DistutilsFileError("can't move '%s': not a regular file" % src)
 
     if isdir(dst):
         dst = os.path.join(dst, basename(src))
     elif exists(dst):
-        raise DistutilsFileError, \
-              "can't move '%s': destination '%s' already exists" % \
-              (src, dst)
+        raise DistutilsFileError("can't move '%s': destination '%s' already "
+                                    "exists" % (src, dst))
 
     if not isdir(dirname(dst)):
-        raise DistutilsFileError, \
-              "can't move '%s': destination '%s' not a valid path" % \
-              (src, dst)
+        raise DistutilsFileError("can't move '%s': destination '%s' not a "
+                                    "valid path" % (src, dst))
 
     copy_it = 0
     try:
@@ -130,8 +127,8 @@
         if num == errno.EXDEV:
             copy_it = 1
         else:
-            raise DistutilsFileError, \
-                  "couldn't move '%s' to '%s': %s" % (src, dst, msg)
+            raise DistutilsFileError("couldn't move '%s' to '%s': %s" %
+                                        (src, dst, msg))
 
     if copy_it:
         distutils.file_util.copy_file(src, dst)
@@ -142,9 +139,7 @@
                 os.unlink(dst)
             except os.error:
                 pass
-            raise DistutilsFileError, \
-                  ("couldn't move '%s' to '%s' by copy/delete: " +
-                   "delete '%s' failed: %s") % \
-                  (src, dst, src, msg)
+            raise DistutilsFileError("couldn't move '%s' to '%s' by copy/delete: "
+                            "delete '%s' failed: %s" % (src, dst, src, msg))
 
     return dst



More information about the Scipy-svn mailing list