Author: Ronan Lamy <[email protected]>
Branch:
Changeset: r71250:65b44c3e6ab8
Date: 2014-05-04 01:19 +0100
http://bitbucket.org/pypy/pypy/changeset/65b44c3e6ab8/
Log: modernise raise syntax
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -353,7 +353,7 @@
result = description.FunctionDesc(self, pyobj)
elif isinstance(pyobj, (type, types.ClassType)):
if pyobj is object:
- raise Exception, "ClassDesc for object not supported"
+ raise Exception("ClassDesc for object not supported")
if pyobj.__module__ == '__builtin__': # avoid making classdefs
for builtin types
result = self.getfrozen(pyobj)
else:
@@ -591,7 +591,7 @@
for name, value in dict.iteritems():
if value is func:
return cls, name
- raise Exception, "could not match bound-method to attribute name: %r" %
(boundmeth,)
+ raise Exception("could not match bound-method to attribute name: %r" %
(boundmeth,))
def ishashable(x):
try:
diff --git a/rpython/annotator/builtin.py b/rpython/annotator/builtin.py
--- a/rpython/annotator/builtin.py
+++ b/rpython/annotator/builtin.py
@@ -65,14 +65,14 @@
s_start, s_stop = args[:2]
s_step = args[2]
else:
- raise Exception, "range() takes 1 to 3 arguments"
+ raise Exception("range() takes 1 to 3 arguments")
empty = False # so far
if not s_step.is_constant():
step = 0 # this case signals a variable step
else:
step = s_step.const
if step == 0:
- raise Exception, "range() with step zero"
+ raise Exception("range() with step zero")
if s_start.is_constant() and s_stop.is_constant():
try:
if len(xrange(s_start.const, s_stop.const, step)) == 0:
diff --git a/rpython/annotator/classdef.py b/rpython/annotator/classdef.py
--- a/rpython/annotator/classdef.py
+++ b/rpython/annotator/classdef.py
@@ -394,7 +394,7 @@
return SomePBC([subdef.classdesc for subdef in self.getallsubdefs()])
def _freeze_(self):
- raise Exception, "ClassDefs are used as knowntype for instances but
cannot be used as immutablevalue arguments directly"
+ raise Exception("ClassDefs are used as knowntype for instances but
cannot be used as immutablevalue arguments directly")
# ____________________________________________________________
diff --git a/rpython/annotator/policy.py b/rpython/annotator/policy.py
--- a/rpython/annotator/policy.py
+++ b/rpython/annotator/policy.py
@@ -30,7 +30,7 @@
except (KeyboardInterrupt, SystemExit):
raise
except:
- raise Exception, "broken specialize directive parms: %s" %
directive
+ raise Exception("broken specialize directive parms: %s" %
directive)
name = name.replace(':', '__')
try:
specializer = getattr(pol, name)
diff --git a/rpython/annotator/test/test_annrpython.py
b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -1435,7 +1435,7 @@
elif a==2:
raise X(1)
elif a==3:
- raise X,4
+ raise X(4)
else:
try:
l[0]
@@ -3628,7 +3628,7 @@
def f():
e = OverflowError()
lle = cast_instance_to_base_ptr(e)
- raise Exception, lle
+ raise Exception(lle)
# ^^^ instead, must cast back from a base ptr to an instance
a = self.RPythonAnnotator()
py.test.raises(AssertionError, a.build_types, f, [])
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit