summaryrefslogtreecommitdiff
path: root/numpy/f2py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-02-26 20:04:59 -0700
committerCharles Harris <charlesr.harris@gmail.com>2013-02-26 20:04:59 -0700
commit705bf928e1256a06019c75ee945370fbe89cdde7 (patch)
tree3e1d8ebcef67a93d8d5eeb63db1256406ae5c49f /numpy/f2py
parent17774a6d58b889b6b7a25d6af5b66f2148d47f41 (diff)
downloadnumpy-705bf928e1256a06019c75ee945370fbe89cdde7.tar.gz
2to3: Use modern exception syntax.
Example: except ValueError,msg: -> except ValueError as msg:
Diffstat (limited to 'numpy/f2py')
-rw-r--r--numpy/f2py/capi_maps.py2
-rwxr-xr-xnumpy/f2py/crackfortran.py8
-rw-r--r--numpy/f2py/diagnose.py18
-rwxr-xr-xnumpy/f2py/f2py2e.py2
-rw-r--r--numpy/f2py/tests/test_array_from_pyobj.py12
-rw-r--r--numpy/f2py/tests/util.py2
6 files changed, 22 insertions, 22 deletions
diff --git a/numpy/f2py/capi_maps.py b/numpy/f2py/capi_maps.py
index dd8277aaf..42d506d74 100644
--- a/numpy/f2py/capi_maps.py
+++ b/numpy/f2py/capi_maps.py
@@ -192,7 +192,7 @@ if os.path.isfile('.f2py_f2cmap'):
else:
errmess("\tIgnoring map {'%s':{'%s':'%s'}}: '%s' must be in %s\n"%(k,k1,d[k][k1],d[k][k1],c2py_map.keys()))
outmess('Succesfully applied user defined changes from .f2py_f2cmap\n')
- except Exception, msg:
+ except Exception as msg:
errmess('Failed to apply user defined changes from .f2py_f2cmap: %s. Skipping.\n' % (msg))
cformat_map={'double':'%g',
'float':'%g',
diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py
index 5d664e399..f610548d6 100755
--- a/numpy/f2py/crackfortran.py
+++ b/numpy/f2py/crackfortran.py
@@ -993,7 +993,7 @@ def analyzeline(m,case,line):
replace(',','+1j*(')
try:
v = eval(initexpr,{},params)
- except (SyntaxError,NameError,TypeError),msg:
+ except (SyntaxError,NameError,TypeError) as msg:
errmess('analyzeline: Failed to evaluate %r. Ignoring: %s\n'\
% (initexpr, msg))
continue
@@ -2034,7 +2034,7 @@ def get_parameters(vars, global_params={}):
l = markoutercomma(v[1:-1]).split('@,@')
try:
params[n] = eval(v,g_params,params)
- except Exception,msg:
+ except Exception as msg:
params[n] = v
#print params
outmess('get_parameters: got "%s" on %s\n' % (msg,`v`))
@@ -2062,7 +2062,7 @@ def _eval_scalar(value,params):
value = str(eval(value,{},params))
except (NameError, SyntaxError):
return value
- except Exception,msg:
+ except Exception as msg:
errmess('"%s" in evaluating %r '\
'(available names: %s)\n' \
% (msg,value,params.keys()))
@@ -2805,7 +2805,7 @@ if __name__ == "__main__":
try:
open(l).close()
files.append(l)
- except IOError,detail:
+ except IOError as detail:
errmess('IOError: %s\n'%str(detail))
else:
funcs.append(l)
diff --git a/numpy/f2py/diagnose.py b/numpy/f2py/diagnose.py
index 3b517a5c9..e45f9950e 100644
--- a/numpy/f2py/diagnose.py
+++ b/numpy/f2py/diagnose.py
@@ -54,7 +54,7 @@ def run():
try:
print 'Found new numpy version %r in %s' % \
(numpy.__version__, numpy.__file__)
- except Exception,msg:
+ except Exception as msg:
print 'error:', msg
print '------'
@@ -62,7 +62,7 @@ def run():
try:
print 'Found f2py2e version %r in %s' % \
(f2py2e.__version__.version,f2py2e.__file__)
- except Exception,msg:
+ except Exception as msg:
print 'error:',msg
print '------'
@@ -77,7 +77,7 @@ def run():
numpy_distutils.numpy_distutils_version.numpy_distutils_version,
numpy_distutils.__file__)
print '------'
- except Exception,msg:
+ except Exception as msg:
print 'error:',msg
print '------'
try:
@@ -91,10 +91,10 @@ def run():
for compiler_class in build_flib.all_compilers:
compiler_class(verbose=1).is_available()
print '------'
- except Exception,msg:
+ except Exception as msg:
print 'error:',msg
print '------'
- except Exception,msg:
+ except Exception as msg:
print 'error:',msg,'(ignore it, build_flib is obsolute for numpy.distutils 0.2.2 and up)'
print '------'
try:
@@ -110,10 +110,10 @@ def run():
print 'Checking availability of supported Fortran compilers:'
fcompiler.show_fcompilers()
print '------'
- except Exception,msg:
+ except Exception as msg:
print 'error:',msg
print '------'
- except Exception,msg:
+ except Exception as msg:
print 'error:',msg
print '------'
try:
@@ -128,7 +128,7 @@ def run():
from numpy_distutils.command.cpuinfo import cpuinfo
print 'ok'
print '------'
- except Exception,msg:
+ except Exception as msg:
print 'error:',msg,'(ignore it)'
print 'Importing numpy_distutils.cpuinfo ...',
from numpy_distutils.cpuinfo import cpuinfo
@@ -140,7 +140,7 @@ def run():
if name[0]=='_' and name[1]!='_' and getattr(cpu,name[1:])():
print name[1:],
print '------'
- except Exception,msg:
+ except Exception as msg:
print 'error:',msg
print '------'
os.chdir(_path)
diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py
index 4e6d2587f..a5935c51b 100755
--- a/numpy/f2py/f2py2e.py
+++ b/numpy/f2py/f2py2e.py
@@ -235,7 +235,7 @@ def scaninputline(inputline):
try:
open(l).close()
files.append(l)
- except IOError,detail:
+ except IOError as detail:
errmess('IOError: %s. Skipping file "%s".\n'%(str(detail),l))
elif f==-1: skipfuncs.append(l)
elif f==0: onlyfuncs.append(l)
diff --git a/numpy/f2py/tests/test_array_from_pyobj.py b/numpy/f2py/tests/test_array_from_pyobj.py
index be85a308a..c1b927c1c 100644
--- a/numpy/f2py/tests/test_array_from_pyobj.py
+++ b/numpy/f2py/tests/test_array_from_pyobj.py
@@ -297,7 +297,7 @@ class _test_shared_memory:
try:
a = self.array([2],intent.in_.inout,self.num2seq)
- except TypeError,msg:
+ except TypeError as msg:
if not str(msg).startswith('failed to initialize intent(inout|inplace|cache) array'):
raise
else:
@@ -313,7 +313,7 @@ class _test_shared_memory:
shape = (len(self.num23seq),len(self.num23seq[0]))
try:
a = self.array(shape,intent.in_.inout,obj)
- except ValueError,msg:
+ except ValueError as msg:
if not str(msg).startswith('failed to initialize intent(inout) array'):
raise
else:
@@ -398,7 +398,7 @@ class _test_shared_memory:
try:
a = self.array(shape,intent.in_.cache,obj[::-1])
- except ValueError,msg:
+ except ValueError as msg:
if not str(msg).startswith('failed to initialize intent(cache) array'):
raise
else:
@@ -411,7 +411,7 @@ class _test_shared_memory:
shape = (len(self.num2seq),)
try:
a = self.array(shape,intent.in_.cache,obj)
- except ValueError,msg:
+ except ValueError as msg:
if not str(msg).startswith('failed to initialize intent(cache) array'):
raise
else:
@@ -429,7 +429,7 @@ class _test_shared_memory:
shape = (-1,3)
try:
a = self.array(shape,intent.cache.hide,None)
- except ValueError,msg:
+ except ValueError as msg:
if not str(msg).startswith('failed to create intent(cache|hide)|optional array'):
raise
else:
@@ -456,7 +456,7 @@ class _test_shared_memory:
shape = (-1,3)
try:
a = self.array(shape,intent.hide,None)
- except ValueError,msg:
+ except ValueError as msg:
if not str(msg).startswith('failed to create intent(cache|hide)|optional array'):
raise
else:
diff --git a/numpy/f2py/tests/util.py b/numpy/f2py/tests/util.py
index a5816b96f..627bc0af9 100644
--- a/numpy/f2py/tests/util.py
+++ b/numpy/f2py/tests/util.py
@@ -71,7 +71,7 @@ def _memoize(func):
if key not in memo:
try:
memo[key] = func(*a, **kw)
- except Exception, e:
+ except Exception as e:
memo[key] = e
raise
ret = memo[key]