Author: Ronan Lamy <[email protected]>
Branch:
Changeset: r71253:6045f686a110
Date: 2014-05-04 03:26 +0100
http://bitbucket.org/pypy/pypy/changeset/6045f686a110/
Log: modernise raise syntax
diff --git a/rpython/translator/backendopt/all.py
b/rpython/translator/backendopt/all.py
--- a/rpython/translator/backendopt/all.py
+++ b/rpython/translator/backendopt/all.py
@@ -22,12 +22,12 @@
try:
mod = __import__(module, {}, {}, ['__doc__'])
except ImportError, e:
- raise Exception, "Import error loading %s: %s" % (dottedname, e)
+ raise Exception("Import error loading %s: %s" % (dottedname, e))
try:
func = getattr(mod, name)
except AttributeError:
- raise Exception, "Function %s not found in module" % dottedname
+ raise Exception("Function %s not found in module" % dottedname)
return func
diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py
--- a/rpython/translator/c/funcgen.py
+++ b/rpython/translator/c/funcgen.py
@@ -178,7 +178,7 @@
else:
return self.db.get(value)
else:
- raise TypeError, "expr(%r)" % (v,)
+ raise TypeError("expr(%r)" % (v,))
# ____________________________________________________________
diff --git a/rpython/translator/c/node.py b/rpython/translator/c/node.py
--- a/rpython/translator/c/node.py
+++ b/rpython/translator/c/node.py
@@ -934,7 +934,7 @@
elif hasattr(fnobj._callable, "c_name"):
return []
else:
- raise ValueError, "don't know how to generate code for %r" % (fnobj,)
+ raise ValueError("don't know how to generate code for %r" % (fnobj,))
class ExtType_OpaqueNode(ContainerNode):
nodekind = 'rpyopaque'
diff --git a/rpython/translator/c/test/test_extfunc.py
b/rpython/translator/c/test/test_extfunc.py
--- a/rpython/translator/c/test/test_extfunc.py
+++ b/rpython/translator/c/test/test_extfunc.py
@@ -627,7 +627,7 @@
elif output.startswith('T'):
return output[1:]
else:
- raise ValueError, 'probing for env var returned %r' % (output,)
+ raise ValueError('probing for env var returned %r' % (output,))
def test_dictlike_environ_getitem():
def fn(s):
diff --git a/rpython/translator/driver.py b/rpython/translator/driver.py
--- a/rpython/translator/driver.py
+++ b/rpython/translator/driver.py
@@ -234,9 +234,9 @@
if os.WIFEXITED(status):
status = os.WEXITSTATUS(status)
if status != 0:
- raise Exception, "instrumentation child failed: %d" %
status
+ raise Exception("instrumentation child failed: %d" %
status)
else:
- raise Exception, "instrumentation child aborted"
+ raise Exception("instrumentation child aborted")
import array, struct
n = datafile.size()//struct.calcsize('L')
datafile = datafile.open('rb')
diff --git a/rpython/translator/gensupp.py b/rpython/translator/gensupp.py
--- a/rpython/translator/gensupp.py
+++ b/rpython/translator/gensupp.py
@@ -39,7 +39,7 @@
before generating any new names."""
for name in txt.split():
if name in self.seennames:
- raise NameError, "%s has already been seen!"
+ raise NameError("%s has already been seen!")
self.seennames[name] = 1
def _ensure_unique(self, basename):
diff --git a/rpython/translator/goal/bpnn.py b/rpython/translator/goal/bpnn.py
--- a/rpython/translator/goal/bpnn.py
+++ b/rpython/translator/goal/bpnn.py
@@ -74,7 +74,7 @@
def update(self, inputs):
if len(inputs) != self.ni-1:
- raise ValueError, 'wrong number of inputs'
+ raise ValueError('wrong number of inputs')
# input activations
for i in range(self.ni-1):
@@ -100,7 +100,7 @@
def backPropagate(self, targets, N, M):
if len(targets) != self.no:
- raise ValueError, 'wrong number of target values'
+ raise ValueError('wrong number of target values')
# calculate error terms for output
output_deltas = [0.0] * self.no
diff --git a/rpython/translator/platform/windows.py
b/rpython/translator/platform/windows.py
--- a/rpython/translator/platform/windows.py
+++ b/rpython/translator/platform/windows.py
@@ -20,8 +20,8 @@
try:
subprocess.check_output([cc, '--version'])
except:
- raise ValueError,"Could not find compiler specified by cc option" + \
- " '%s', it must be a valid exe file on your path"%cc
+ raise ValueError("Could not find compiler specified by cc option '%s',"
+ " it must be a valid exe file on your path" % cc)
return MingwPlatform(cc)
def Windows(cc=None):
@@ -31,7 +31,7 @@
raise Exception("Win64 is not supported. You must either build for Win32"
" or contribute the missing support in PyPy.")
return _get_compiler_type(cc, True)
-
+
def _get_msvc_env(vsver, x64flag):
try:
toolsdir = os.environ['VS%sCOMNTOOLS' % vsver]
@@ -94,7 +94,7 @@
name = "msvc"
so_ext = 'dll'
exe_ext = 'exe'
-
+
relevant_environ = ('PATH', 'INCLUDE', 'LIB')
cc = 'cl.exe'
@@ -105,7 +105,7 @@
standalone_only = ()
shared_only = ()
environ = None
-
+
def __init__(self, cc=None, x64=False):
self.x64 = x64
msvc_compiler_environ = find_msvc_env(x64)
@@ -134,7 +134,7 @@
else:
masm32 = 'ml.exe'
masm64 = 'ml64.exe'
-
+
if x64:
self.masm = masm64
else:
@@ -338,10 +338,10 @@
definitions.append(('CREATE_PCH', '/Ycstdafx.h /Fpstdafx.pch
/FIstdafx.h'))
definitions.append(('USE_PCH', '/Yustdafx.h /Fpstdafx.pch
/FIstdafx.h'))
rules.append(('$(OBJECTS)', 'stdafx.pch', []))
- rules.append(('stdafx.pch', 'stdafx.h',
+ rules.append(('stdafx.pch', 'stdafx.h',
'$(CC) stdafx.c /c /nologo $(CFLAGS) $(CFLAGSEXTRA) '
'$(CREATE_PCH) $(INCLUDEDIRS)'))
- rules.append(('.c.obj', '',
+ rules.append(('.c.obj', '',
'$(CC) /nologo $(CFLAGS) $(CFLAGSEXTRA) $(USE_PCH) '
'/Fo$@ /c $< $(INCLUDEDIRS)'))
#Do not use precompiled headers for some files
@@ -361,7 +361,7 @@
'/Fo%s /c %s $(INCLUDEDIRS)' %(target, f)))
else:
- rules.append(('.c.obj', '',
+ rules.append(('.c.obj', '',
'$(CC) /nologo $(CFLAGS) $(CFLAGSEXTRA) '
'/Fo$@ /c $< $(INCLUDEDIRS)'))
@@ -371,7 +371,7 @@
for rule in rules:
m.rule(*rule)
-
+
if self.version < 80:
m.rule('$(TARGET)', '$(OBJECTS)',
[ '$(CC_LINK) /nologo $(LDFLAGS) $(LDFLAGSEXTRA) /out:$@'
+\
diff --git a/rpython/translator/translator.py b/rpython/translator/translator.py
--- a/rpython/translator/translator.py
+++ b/rpython/translator/translator.py
@@ -116,7 +116,7 @@
print >>f, " ",op
print >>f, '--end--'
return
- raise TypeError, "don't know about %r" % x
+ raise TypeError("don't know about %r" % x)
def view(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit