[pypy-svn] r65522 - in pypy/trunk/pypy: annotation annotation/test doc/tool interpreter interpreter/astcompiler lib lib/app_test lib/app_test/ctypes_tests lib/xml/dom lib/xml/sax module/__builtin__ module/__builtin__/test module/_sre module/_stackless/test module/clr module/fcntl module/operator module/posix module/sys module/sys/test module/unicodedata objspace objspace/flow objspace/flow/test objspace/std objspace/std/test objspace/test rlib rlib/test rpython rpython/lltypesystem rpython/ootypesystem tool tool/algo tool/test translator translator/backendopt translator/c translator/c/test translator/cli translator/cli/test translator/goal translator/goal/win32 translator/jvm/test translator/stackless translator/stackless/test translator/test translator/tool
benjamin at codespeak.net
benjamin at codespeak.net
Mon Jun 1 02:01:09 CEST 2009
Author: benjamin
Date: Mon Jun 1 02:00:54 2009
New Revision: 65522
Modified:
pypy/trunk/pypy/annotation/annrpython.py
pypy/trunk/pypy/annotation/binaryop.py
pypy/trunk/pypy/annotation/bookkeeper.py
pypy/trunk/pypy/annotation/builtin.py
pypy/trunk/pypy/annotation/classdef.py
pypy/trunk/pypy/annotation/description.py
pypy/trunk/pypy/annotation/policy.py
pypy/trunk/pypy/annotation/test/test_annrpython.py
pypy/trunk/pypy/annotation/unaryop.py
pypy/trunk/pypy/doc/tool/makecontributor.py
pypy/trunk/pypy/doc/tool/mydot.py
pypy/trunk/pypy/interpreter/argument.py
pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py
pypy/trunk/pypy/interpreter/baseobjspace.py
pypy/trunk/pypy/interpreter/eval.py
pypy/trunk/pypy/interpreter/gateway.py
pypy/trunk/pypy/interpreter/miscutils.py
pypy/trunk/pypy/interpreter/nestedscope.py
pypy/trunk/pypy/interpreter/pyframe.py
pypy/trunk/pypy/interpreter/pyopcode.py
pypy/trunk/pypy/lib/__init__.py
pypy/trunk/pypy/lib/_marshal.py
pypy/trunk/pypy/lib/_sre.py
pypy/trunk/pypy/lib/app_test/ctypes_tests/test_callback_traceback.py
pypy/trunk/pypy/lib/app_test/ctypes_tests/test_cfuncs.py
pypy/trunk/pypy/lib/app_test/ctypes_tests/test_structures.py
pypy/trunk/pypy/lib/app_test/test_functools.py
pypy/trunk/pypy/lib/collections.py
pypy/trunk/pypy/lib/datetime.py
pypy/trunk/pypy/lib/hashlib.py
pypy/trunk/pypy/lib/imp.py
pypy/trunk/pypy/lib/itertools.py
pypy/trunk/pypy/lib/pstats.py
pypy/trunk/pypy/lib/stackless.py
pypy/trunk/pypy/lib/struct.py
pypy/trunk/pypy/lib/xml/dom/domreg.py
pypy/trunk/pypy/lib/xml/dom/expatbuilder.py
pypy/trunk/pypy/lib/xml/dom/minidom.py
pypy/trunk/pypy/lib/xml/sax/xmlreader.py
pypy/trunk/pypy/module/__builtin__/app_functional.py
pypy/trunk/pypy/module/__builtin__/app_inspect.py
pypy/trunk/pypy/module/__builtin__/test/test_classobj.py
pypy/trunk/pypy/module/__builtin__/test/test_descriptor.py
pypy/trunk/pypy/module/_sre/app_sre.py
pypy/trunk/pypy/module/_stackless/test/test_greenlet.py
pypy/trunk/pypy/module/clr/app_clr.py
pypy/trunk/pypy/module/fcntl/app_fcntl.py
pypy/trunk/pypy/module/operator/app_operator.py
pypy/trunk/pypy/module/posix/app_posix.py
pypy/trunk/pypy/module/sys/app.py
pypy/trunk/pypy/module/sys/test/test_sysmodule.py
pypy/trunk/pypy/module/unicodedata/interp_ucd.py
pypy/trunk/pypy/module/unicodedata/unicodedb_4_1_0.py
pypy/trunk/pypy/objspace/descroperation.py
pypy/trunk/pypy/objspace/flow/flowcontext.py
pypy/trunk/pypy/objspace/flow/objspace.py
pypy/trunk/pypy/objspace/flow/specialcase.py
pypy/trunk/pypy/objspace/flow/test/test_objspace.py
pypy/trunk/pypy/objspace/std/boolobject.py
pypy/trunk/pypy/objspace/std/model.py
pypy/trunk/pypy/objspace/std/mro.py
pypy/trunk/pypy/objspace/std/multimethod.py
pypy/trunk/pypy/objspace/std/objspace.py
pypy/trunk/pypy/objspace/std/register_all.py
pypy/trunk/pypy/objspace/std/stdtypedef.py
pypy/trunk/pypy/objspace/std/strutil.py
pypy/trunk/pypy/objspace/std/test/test_dictproxy.py
pypy/trunk/pypy/objspace/std/test/test_intobject.py
pypy/trunk/pypy/objspace/std/test/test_typeobject.py
pypy/trunk/pypy/objspace/test/test_descroperation.py
pypy/trunk/pypy/rlib/objectmodel.py
pypy/trunk/pypy/rlib/rarithmetic.py
pypy/trunk/pypy/rlib/rzipfile.py
pypy/trunk/pypy/rlib/test/test_streamio.py
pypy/trunk/pypy/rpython/callparse.py
pypy/trunk/pypy/rpython/llinterp.py
pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
pypy/trunk/pypy/rpython/lltypesystem/lltype.py
pypy/trunk/pypy/rpython/lltypesystem/rclass.py
pypy/trunk/pypy/rpython/lltypesystem/rstr.py
pypy/trunk/pypy/rpython/ootypesystem/ootype.py
pypy/trunk/pypy/rpython/ootypesystem/rstr.py
pypy/trunk/pypy/rpython/rlist.py
pypy/trunk/pypy/rpython/rmodel.py
pypy/trunk/pypy/rpython/rstr.py
pypy/trunk/pypy/tool/_enum_exceptions_broken.py
pypy/trunk/pypy/tool/algo/unionfind.py
pypy/trunk/pypy/tool/cache.py
pypy/trunk/pypy/tool/importfun.py
pypy/trunk/pypy/tool/isolate.py
pypy/trunk/pypy/tool/makerelease.py
pypy/trunk/pypy/tool/pydis.py
pypy/trunk/pypy/tool/test/isolate_simple.py
pypy/trunk/pypy/tool/test/test_pytestsupport.py
pypy/trunk/pypy/translator/backendopt/all.py
pypy/trunk/pypy/translator/backendopt/malloc.py
pypy/trunk/pypy/translator/c/funcgen.py
pypy/trunk/pypy/translator/c/node.py
pypy/trunk/pypy/translator/c/test/test_extfunc.py
pypy/trunk/pypy/translator/cli/carbonpython.py
pypy/trunk/pypy/translator/cli/dotnet.py
pypy/trunk/pypy/translator/cli/test/runtest.py
pypy/trunk/pypy/translator/driver.py
pypy/trunk/pypy/translator/geninterplevel.py
pypy/trunk/pypy/translator/gensupp.py
pypy/trunk/pypy/translator/goal/bench-windows.py
pypy/trunk/pypy/translator/goal/win32/gc_patch_windows.py
pypy/trunk/pypy/translator/jvm/test/runtest.py
pypy/trunk/pypy/translator/stackless/test/test_transform.py
pypy/trunk/pypy/translator/stackless/transform.py
pypy/trunk/pypy/translator/test/snippet.py
pypy/trunk/pypy/translator/tool/taskengine.py
pypy/trunk/pypy/translator/translator.py
Log:
normalize raise statements
Modified: pypy/trunk/pypy/annotation/annrpython.py
==============================================================================
--- pypy/trunk/pypy/annotation/annrpython.py (original)
+++ pypy/trunk/pypy/annotation/annrpython.py Mon Jun 1 02:00:54 2009
@@ -202,7 +202,7 @@
else:
return object
else:
- raise TypeError, ("Variable or Constant instance expected, "
+ raise TypeError("Variable or Constant instance expected, "
"got %r" % (variable,))
def getuserclassdefinitions(self):
@@ -288,7 +288,7 @@
# return annmodel.s_ImpossibleValue
return self.bookkeeper.immutableconstant(arg)
else:
- raise TypeError, 'Variable or Constant expected, got %r' % (arg,)
+ raise TypeError('Variable or Constant expected, got %r' % (arg,))
def typeannotation(self, t):
return signature.annotation(t, self.bookkeeper)
@@ -717,7 +717,7 @@
consider_meth = getattr(self,'consider_op_'+op.opname,
None)
if not consider_meth:
- raise Exception,"unknown op: %r" % op
+ raise Exception("unknown op: %r" % op)
# let's be careful about avoiding propagated SomeImpossibleValues
# to enter an op; the latter can result in violations of the
Modified: pypy/trunk/pypy/annotation/binaryop.py
==============================================================================
--- pypy/trunk/pypy/annotation/binaryop.py (original)
+++ pypy/trunk/pypy/annotation/binaryop.py Mon Jun 1 02:00:54 2009
@@ -967,8 +967,8 @@
class __extend__(pairtype(SomeAddress, SomeObject)):
def union((s_addr, s_obj)):
- raise UnionError, "union of address and anything else makes no sense"
+ raise UnionError("union of address and anything else makes no sense")
class __extend__(pairtype(SomeObject, SomeAddress)):
def union((s_obj, s_addr)):
- raise UnionError, "union of address and anything else makes no sense"
+ raise UnionError("union of address and anything else makes no sense")
Modified: pypy/trunk/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/trunk/pypy/annotation/bookkeeper.py (original)
+++ pypy/trunk/pypy/annotation/bookkeeper.py Mon Jun 1 02:00:54 2009
@@ -468,7 +468,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:
@@ -689,7 +689,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:
@@ -715,7 +715,7 @@
return SomeTuple(items_s)
def newdict(self):
- raise CallPatternTooComplex, "'**' argument"
+ raise CallPatternTooComplex("'**' argument")
def unpackiterable(self, s_obj, expected_length=None):
if isinstance(s_obj, SomeTuple):
@@ -726,7 +726,7 @@
if (s_obj.__class__ is SomeObject and
getattr(s_obj, 'from_ellipsis', False)): # see newtuple()
return [Ellipsis]
- raise CallPatternTooComplex, "'*' argument must be SomeTuple"
+ raise CallPatternTooComplex("'*' argument must be SomeTuple")
def is_w(self, one, other):
return one is other
Modified: pypy/trunk/pypy/annotation/builtin.py
==============================================================================
--- pypy/trunk/pypy/annotation/builtin.py (original)
+++ pypy/trunk/pypy/annotation/builtin.py Mon Jun 1 02:00:54 2009
@@ -56,14 +56,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:
@@ -350,7 +350,7 @@
## return SomeInteger()
def unicodedata_decimal(s_uchr):
- raise TypeError, "unicodedate.decimal() calls should not happen at interp-level"
+ raise TypeError("unicodedate.decimal() calls should not happen at interp-level")
def test(*args):
return s_Bool
@@ -556,14 +556,14 @@
if ootype.isSubclass(i.ootype, I.const):
return SomeOOInstance(I.const)
else:
- raise AnnotatorError, 'Cannot cast %s to %s' % (i.ootype, I.const)
+ raise AnnotatorError('Cannot cast %s to %s' % (i.ootype, I.const))
def oodowncast(I, i):
assert isinstance(I.const, ootype.Instance)
if ootype.isSubclass(I.const, i.ootype):
return SomeOOInstance(I.const)
else:
- raise AnnotatorError, 'Cannot cast %s to %s' % (i.ootype, I.const)
+ raise AnnotatorError('Cannot cast %s to %s' % (i.ootype, I.const))
BUILTIN_ANALYZERS[ootype.instanceof] = instanceof
BUILTIN_ANALYZERS[ootype.new] = new
Modified: pypy/trunk/pypy/annotation/classdef.py
==============================================================================
--- pypy/trunk/pypy/annotation/classdef.py (original)
+++ pypy/trunk/pypy/annotation/classdef.py Mon Jun 1 02:00:54 2009
@@ -396,7 +396,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")
# ____________________________________________________________
Modified: pypy/trunk/pypy/annotation/description.py
==============================================================================
--- pypy/trunk/pypy/annotation/description.py (original)
+++ pypy/trunk/pypy/annotation/description.py Mon Jun 1 02:00:54 2009
@@ -245,7 +245,7 @@
try:
inputcells = args.match_signature(signature, defs_s)
except ArgErr, e:
- raise TypeError, "signature mismatch: %s" % e.getmsg(self.name)
+ raise TypeError("signature mismatch: %s" % e.getmsg(self.name))
return inputcells
def specialize(self, inputcells):
Modified: pypy/trunk/pypy/annotation/policy.py
==============================================================================
--- pypy/trunk/pypy/annotation/policy.py (original)
+++ pypy/trunk/pypy/annotation/policy.py Mon Jun 1 02:00:54 2009
@@ -53,7 +53,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)
@@ -63,7 +63,7 @@
if directive.startswith('override:'):
# different signature: override__xyz(*args_s)
if parms:
- raise Exception, "override:* specialisations don't support parameters"
+ raise Exception("override:* specialisations don't support parameters")
def specialize_override(funcdesc, args_s):
funcdesc.overridden = True
return specializer(*args_s)
Modified: pypy/trunk/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/trunk/pypy/annotation/test/test_annrpython.py (original)
+++ pypy/trunk/pypy/annotation/test/test_annrpython.py Mon Jun 1 02:00:54 2009
@@ -1267,7 +1267,7 @@
elif a==2:
raise X(1)
elif a==3:
- raise X,4
+ raise X(4)
else:
try:
l[0]
Modified: pypy/trunk/pypy/annotation/unaryop.py
==============================================================================
--- pypy/trunk/pypy/annotation/unaryop.py (original)
+++ pypy/trunk/pypy/annotation/unaryop.py Mon Jun 1 02:00:54 2009
@@ -35,7 +35,7 @@
def type(obj, *moreargs):
if moreargs:
- raise Exception, 'type() called with more than one argument'
+ raise Exception('type() called with more than one argument')
if obj.is_constant():
if isinstance(obj, SomeInstance):
r = SomePBC([obj.classdef.classdesc])
@@ -97,7 +97,7 @@
return obj.is_true()
def hash(obj):
- raise TypeError, "hash() is not generally supported"
+ raise TypeError("hash() is not generally supported")
def str(obj):
getbookkeeper().count('str', obj)
Modified: pypy/trunk/pypy/doc/tool/makecontributor.py
==============================================================================
--- pypy/trunk/pypy/doc/tool/makecontributor.py (original)
+++ pypy/trunk/pypy/doc/tool/makecontributor.py Mon Jun 1 02:00:54 2009
@@ -9,7 +9,7 @@
path = py.std.sys.argv[1]
except IndexError:
print "usage: %s PATH" %(py.std.sys.argv[0])
- raise SystemExit, 1
+ raise SystemExit(1)
d = {}
Modified: pypy/trunk/pypy/doc/tool/mydot.py
==============================================================================
--- pypy/trunk/pypy/doc/tool/mydot.py (original)
+++ pypy/trunk/pypy/doc/tool/mydot.py Mon Jun 1 02:00:54 2009
@@ -68,7 +68,7 @@
help="output format")
options, args = parser.parse_args()
if len(args) != 1:
- raise ValueError, "need exactly one argument"
+ raise ValueError("need exactly one argument")
epsfile = process_dot(py.path.local(args[0]))
if options.format == "ps" or options.format == "eps":
print epsfile.read()
Modified: pypy/trunk/pypy/interpreter/argument.py
==============================================================================
--- pypy/trunk/pypy/interpreter/argument.py (original)
+++ pypy/trunk/pypy/interpreter/argument.py Mon Jun 1 02:00:54 2009
@@ -223,9 +223,9 @@
def fixedunpack(self, argcount):
if self.nargs > argcount:
- raise ValueError, "too many arguments (%d expected)" % argcount
+ raise ValueError("too many arguments (%d expected)" % argcount)
elif self.nargs < argcount:
- raise ValueError, "not enough arguments (%d expected)" % argcount
+ raise ValueError("not enough arguments (%d expected)" % argcount)
data_w = [None] * self.nargs
nargs = self.nargs
for i in range(nargs):
@@ -409,16 +409,16 @@
"""The simplest argument parsing: get the 'argcount' arguments,
or raise a real ValueError if the length is wrong."""
if self.has_keywords():
- raise ValueError, "no keyword arguments expected"
+ raise ValueError("no keyword arguments expected")
if len(self.arguments_w) > argcount:
- raise ValueError, "too many arguments (%d expected)" % argcount
+ raise ValueError("too many arguments (%d expected)" % argcount)
if self.w_stararg is not None:
self.arguments_w = (self.arguments_w +
self.space.viewiterable(self.w_stararg,
argcount - len(self.arguments_w)))
self.w_stararg = None
elif len(self.arguments_w) < argcount:
- raise ValueError, "not enough arguments (%d expected)" % argcount
+ raise ValueError("not enough arguments (%d expected)" % argcount)
return self.arguments_w
def firstarg(self):
Modified: pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py
==============================================================================
--- pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py (original)
+++ pypy/trunk/pypy/interpreter/astcompiler/pycodegen.py Mon Jun 1 02:00:54 2009
@@ -38,7 +38,7 @@
def compile(source, filename, mode, flags=None, dont_inherit=None):
"""Replacement for builtin compile() function"""
if flags is not None or dont_inherit is not None:
- raise RuntimeError, "not implemented yet"
+ raise RuntimeError("not implemented yet")
if mode == "single":
gen = Interactive(source, filename)
Modified: pypy/trunk/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/trunk/pypy/interpreter/baseobjspace.py (original)
+++ pypy/trunk/pypy/interpreter/baseobjspace.py Mon Jun 1 02:00:54 2009
@@ -850,7 +850,7 @@
expression = PyCode._from_code(self, expression,
hidden_applevel=hidden_applevel)
if not isinstance(expression, PyCode):
- raise TypeError, 'space.eval(): expected a string, code or PyCode object'
+ raise TypeError('space.eval(): expected a string, code or PyCode object')
return expression.exec_code(self, w_globals, w_locals)
def exec_(self, statement, w_globals, w_locals, hidden_applevel=False):
@@ -863,7 +863,7 @@
statement = PyCode._from_code(self, statement,
hidden_applevel=hidden_applevel)
if not isinstance(statement, PyCode):
- raise TypeError, 'space.exec_(): expected a string, code or PyCode object'
+ raise TypeError('space.exec_(): expected a string, code or PyCode object')
w_key = self.wrap('__builtins__')
if not self.is_true(self.contains(w_globals, w_key)):
self.setitem(w_globals, w_key, self.wrap(self.builtin))
Modified: pypy/trunk/pypy/interpreter/eval.py
==============================================================================
--- pypy/trunk/pypy/interpreter/eval.py (original)
+++ pypy/trunk/pypy/interpreter/eval.py Mon Jun 1 02:00:54 2009
@@ -78,7 +78,7 @@
def run(self):
"Abstract method to override. Runs the frame"
- raise TypeError, "abstract"
+ raise TypeError("abstract")
def getdictscope(self):
"Get the locals as a dictionary."
@@ -101,12 +101,12 @@
def getfastscope(self):
"Abstract. Get the fast locals as a list."
- raise TypeError, "abstract"
+ raise TypeError("abstract")
def setfastscope(self, scope_w):
"""Abstract. Initialize the fast locals from a list of values,
where the order is according to self.getcode().signature()."""
- raise TypeError, "abstract"
+ raise TypeError("abstract")
def fast2locals(self):
# Copy values from self.fastlocals_w to self.w_locals
Modified: pypy/trunk/pypy/interpreter/gateway.py
==============================================================================
--- pypy/trunk/pypy/interpreter/gateway.py (original)
+++ pypy/trunk/pypy/interpreter/gateway.py Mon Jun 1 02:00:54 2009
@@ -278,7 +278,7 @@
def _run(self, space, scope_w):
"""Subclasses with behavior specific for an unwrap spec are generated"""
- raise TypeError, "abstract"
+ raise TypeError("abstract")
#________________________________________________________________
@@ -731,10 +731,10 @@
self_type = f.im_class
f = f.im_func
if not isinstance(f, types.FunctionType):
- raise TypeError, "function expected, got %r instead" % f
+ raise TypeError("function expected, got %r instead" % f)
if app_name is None:
if f.func_name.startswith('app_'):
- raise ValueError, ("function name %r suspiciously starts "
+ raise ValueError("function name %r suspiciously starts "
"with 'app_'" % f.func_name)
app_name = f.func_name
Modified: pypy/trunk/pypy/interpreter/miscutils.py
==============================================================================
--- pypy/trunk/pypy/interpreter/miscutils.py (original)
+++ pypy/trunk/pypy/interpreter/miscutils.py Mon Jun 1 02:00:54 2009
@@ -41,18 +41,18 @@
"""'position' is 0 for the top of the stack, 1 for the item below,
and so on. It must not be negative."""
if position < 0:
- raise ValueError, 'negative stack position'
+ raise ValueError('negative stack position')
if position >= len(self.items):
- raise IndexError, 'not enough entries in stack'
+ raise IndexError('not enough entries in stack')
return self.items[~position]
def set_top(self, value, position=0):
"""'position' is 0 for the top of the stack, 1 for the item below,
and so on. It must not be negative."""
if position < 0:
- raise ValueError, 'negative stack position'
+ raise ValueError('negative stack position')
if position >= len(self.items):
- raise IndexError, 'not enough entries in stack'
+ raise IndexError('not enough entries in stack')
self.items[~position] = value
def depth(self):
Modified: pypy/trunk/pypy/interpreter/nestedscope.py
==============================================================================
--- pypy/trunk/pypy/interpreter/nestedscope.py (original)
+++ pypy/trunk/pypy/interpreter/nestedscope.py Mon Jun 1 02:00:54 2009
@@ -18,7 +18,7 @@
def get(self):
if self.w_value is None:
- raise ValueError, "get() from an empty cell"
+ raise ValueError("get() from an empty cell")
return self.w_value
def set(self, w_value):
@@ -26,7 +26,7 @@
def delete(self):
if self.w_value is None:
- raise ValueError, "delete() on an empty cell"
+ raise ValueError("delete() on an empty cell")
self.w_value = None
def descr__eq__(self, space, w_other):
Modified: pypy/trunk/pypy/interpreter/pyframe.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pyframe.py (original)
+++ pypy/trunk/pypy/interpreter/pyframe.py Mon Jun 1 02:00:54 2009
@@ -373,7 +373,7 @@
where the order is according to self.pycode.signature()."""
scope_len = len(scope_w)
if scope_len > len(self.fastlocals_w):
- raise ValueError, "new fastscope is longer than the allocated area"
+ raise ValueError("new fastscope is longer than the allocated area")
self.fastlocals_w[:scope_len] = scope_w
self.init_cells()
Modified: pypy/trunk/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pyopcode.py (original)
+++ pypy/trunk/pypy/interpreter/pyopcode.py Mon Jun 1 02:00:54 2009
@@ -763,7 +763,7 @@
w_result = getattr(f, attr)(w_1, w_2)
break
else:
- raise BytecodeCorruption, "bad COMPARE_OP oparg"
+ raise BytecodeCorruption("bad COMPARE_OP oparg")
f.pushvalue(w_result)
def IMPORT_NAME(f, nameindex, *ignored):
@@ -853,7 +853,7 @@
return next_instr
def FOR_LOOP(f, oparg, *ignored):
- raise BytecodeCorruption, "old opcode, no longer in use"
+ raise BytecodeCorruption("old opcode, no longer in use")
def SETUP_LOOP(f, offsettoend, next_instr, *ignored):
block = LoopBlock(f, next_instr + offsettoend)
Modified: pypy/trunk/pypy/lib/__init__.py
==============================================================================
--- pypy/trunk/pypy/lib/__init__.py (original)
+++ pypy/trunk/pypy/lib/__init__.py Mon Jun 1 02:00:54 2009
@@ -1,4 +1,4 @@
# This __init__.py shows up in PyPy's app-level standard library.
# Let's try to prevent that confusion...
if __name__ != 'pypy.lib':
- raise ImportError, '__init__'
+ raise ImportError('__init__')
Modified: pypy/trunk/pypy/lib/_marshal.py
==============================================================================
--- pypy/trunk/pypy/lib/_marshal.py (original)
+++ pypy/trunk/pypy/lib/_marshal.py Mon Jun 1 02:00:54 2009
@@ -50,7 +50,7 @@
if func:
break
else:
- raise ValueError, "unmarshallable object"
+ raise ValueError("unmarshallable object")
func(self, x)
def w_long64(self, x):
@@ -84,7 +84,7 @@
def dump_stopiter(self, x):
if x is not StopIteration:
- raise ValueError, "unmarshallable object"
+ raise ValueError("unmarshallable object")
self._write(TYPE_STOPITER)
dispatch[type(StopIteration)] = dump_stopiter
@@ -253,7 +253,7 @@
try:
return self.dispatch[c](self)
except KeyError:
- raise ValueError, "bad marshal code: %c (%d)" % (c, ord(c))
+ raise ValueError("bad marshal code: %c (%d)" % (c, ord(c)))
def r_short(self):
lo = ord(self._read(1))
@@ -410,7 +410,7 @@
firstlineno = self.r_long()
lnotab = self.load()
if not new:
- raise RuntimeError, "can't unmarshal code objects; no 'new' module"
+ raise RuntimeError("can't unmarshal code objects; no 'new' module")
return new.code(argcount, nlocals, stacksize, flags, code, consts,
names, varnames, filename, name, firstlineno, lnotab,
freevars, cellvars)
@@ -500,7 +500,7 @@
self.bufpos += 1
return _load_dispatch[c](self)
except KeyError:
- raise ValueError, "bad marshal code: %c (%d)" % (c, ord(c))
+ raise ValueError("bad marshal code: %c (%d)" % (c, ord(c)))
except IndexError:
raise EOFError
@@ -628,7 +628,7 @@
firstlineno = _r_long(self)
lnotab = self.load()
if not new:
- raise RuntimeError, "can't unmarshal code objects; no 'new' module"
+ raise RuntimeError("can't unmarshal code objects; no 'new' module")
return new.code(argcount, nlocals, stacksize, flags, code, consts,
names, varnames, filename, name, firstlineno, lnotab,
freevars, cellvars)
Modified: pypy/trunk/pypy/lib/_sre.py
==============================================================================
--- pypy/trunk/pypy/lib/_sre.py (original)
+++ pypy/trunk/pypy/lib/_sre.py Mon Jun 1 02:00:54 2009
@@ -191,10 +191,10 @@
return SRE_Scanner(self, string, start, end)
def __copy__(self):
- raise TypeError, "cannot copy this pattern object"
+ raise TypeError("cannot copy this pattern object")
def __deepcopy__(self):
- raise TypeError, "cannot copy this pattern object"
+ raise TypeError("cannot copy this pattern object")
class SRE_Scanner(object):
@@ -331,10 +331,10 @@
return tuple(grouplist)
def __copy__():
- raise TypeError, "cannot copy this pattern object"
+ raise TypeError("cannot copy this pattern object")
def __deepcopy__():
- raise TypeError, "cannot copy this pattern object"
+ raise TypeError("cannot copy this pattern object")
class _State(object):
Modified: pypy/trunk/pypy/lib/app_test/ctypes_tests/test_callback_traceback.py
==============================================================================
--- pypy/trunk/pypy/lib/app_test/ctypes_tests/test_callback_traceback.py (original)
+++ pypy/trunk/pypy/lib/app_test/ctypes_tests/test_callback_traceback.py Mon Jun 1 02:00:54 2009
@@ -5,7 +5,7 @@
def callback_func(arg):
42 / arg
- raise ValueError, arg
+ raise ValueError(arg)
class TestCallbackTraceback:
# When an exception is raised in a ctypes callback function, the C
Modified: pypy/trunk/pypy/lib/app_test/ctypes_tests/test_cfuncs.py
==============================================================================
--- pypy/trunk/pypy/lib/app_test/ctypes_tests/test_cfuncs.py (original)
+++ pypy/trunk/pypy/lib/app_test/ctypes_tests/test_cfuncs.py Mon Jun 1 02:00:54 2009
@@ -190,7 +190,7 @@
class stdcall_dll(WinDLL):
def __getattr__(self, name):
if name[:2] == '__' and name[-2:] == '__':
- raise AttributeError, name
+ raise AttributeError(name)
func = self._FuncPtr(("s_" + name, self))
setattr(self, name, func)
return func
Modified: pypy/trunk/pypy/lib/app_test/ctypes_tests/test_structures.py
==============================================================================
--- pypy/trunk/pypy/lib/app_test/ctypes_tests/test_structures.py (original)
+++ pypy/trunk/pypy/lib/app_test/ctypes_tests/test_structures.py Mon Jun 1 02:00:54 2009
@@ -445,7 +445,7 @@
assert ("Structure or union cannot contain itself" in
str(details))
else:
- raise AssertionError, "Structure or union cannot contain itself"
+ raise AssertionError("Structure or union cannot contain itself")
def test_vice_versa(self):
@@ -463,7 +463,7 @@
assert ("_fields_ is final" in
str(details))
else:
- raise AssertionError, "AttributeError not raised"
+ raise AssertionError("AttributeError not raised")
class TestPatologicalCases(BaseCTypesTestChecker):
@@ -472,7 +472,7 @@
_fields_ = [('x', c_int)]
def __getattr__(self, name):
- raise AttributeError, name
+ raise AttributeError(name)
x = X()
assert x.x == 0
Modified: pypy/trunk/pypy/lib/app_test/test_functools.py
==============================================================================
--- pypy/trunk/pypy/lib/app_test/test_functools.py (original)
+++ pypy/trunk/pypy/lib/app_test/test_functools.py Mon Jun 1 02:00:54 2009
@@ -51,7 +51,7 @@
except TypeError:
pass
else:
- raise AssertionError, 'First arg not checked for callability'
+ raise AssertionError('First arg not checked for callability')
def test_protection_of_callers_dict_argument(self):
# a caller's dictionary should not be altered by partial
@@ -125,7 +125,7 @@
except (TypeError, AttributeError):
pass
else:
- raise AssertionError, 'partial object allowed __dict__ to be deleted'
+ raise AssertionError('partial object allowed __dict__ to be deleted')
def test_weakref(self):
f = self.thetype(int, base=16)
Modified: pypy/trunk/pypy/lib/collections.py
==============================================================================
--- pypy/trunk/pypy/lib/collections.py (original)
+++ pypy/trunk/pypy/lib/collections.py Mon Jun 1 02:00:54 2009
@@ -71,7 +71,7 @@
def pop(self):
if self.left is self.right and self.leftndx > self.rightndx:
- raise IndexError, "pop from an empty deque"
+ raise IndexError("pop from an empty deque")
x = self.right[self.rightndx]
self.right[self.rightndx] = None
self.length -= 1
@@ -92,7 +92,7 @@
def popleft(self):
if self.left is self.right and self.leftndx > self.rightndx:
- raise IndexError, "pop from an empty deque"
+ raise IndexError("pop from an empty deque")
x = self.left[self.leftndx]
self.left[self.leftndx] = None
self.length -= 1
@@ -252,7 +252,7 @@
return type(self), (), self.__dict__, iter(self), None
def __hash__(self):
- raise TypeError, "deque objects are unhashable"
+ raise TypeError("deque objects are unhashable")
def __copy__(self):
return self.__class__(self)
@@ -300,7 +300,7 @@
self.counter = len(deq)
def giveup():
self.counter = 0
- raise RuntimeError, "deque mutated during iteration"
+ raise RuntimeError("deque mutated during iteration")
self._gen = itergen(deq.state, giveup)
def next(self):
Modified: pypy/trunk/pypy/lib/datetime.py
==============================================================================
--- pypy/trunk/pypy/lib/datetime.py (original)
+++ pypy/trunk/pypy/lib/datetime.py Mon Jun 1 02:00:54 2009
@@ -1757,7 +1757,7 @@
if myoff == otoff:
return base
if myoff is None or otoff is None:
- raise TypeError, "cannot mix naive and timezone-aware time"
+ raise TypeError("cannot mix naive and timezone-aware time")
return base + timedelta(minutes = otoff-myoff)
def __hash__(self):
Modified: pypy/trunk/pypy/lib/hashlib.py
==============================================================================
--- pypy/trunk/pypy/lib/hashlib.py (original)
+++ pypy/trunk/pypy/lib/hashlib.py Mon Jun 1 02:00:54 2009
@@ -74,7 +74,7 @@
elif name in ('SHA384', 'sha384'):
import _sha512
return _sha512.sha384
- raise ValueError, "unsupported hash type"
+ raise ValueError("unsupported hash type")
def __hash_new(name, string=''):
"""new(name, string='') - Return a new hashing object using the named algorithm;
Modified: pypy/trunk/pypy/lib/imp.py
==============================================================================
--- pypy/trunk/pypy/lib/imp.py (original)
+++ pypy/trunk/pypy/lib/imp.py Mon Jun 1 02:00:54 2009
@@ -55,7 +55,7 @@
for ext, mode, kind in get_suffixes():
if os.path.exists(filename+ext):
return (file(filename+ext, mode), filename+ext, (ext, mode, kind))
- raise ImportError, 'No module named %s' % (name,)
+ raise ImportError('No module named %s' % (name,))
def load_module(name, file, filename, description):
@@ -82,7 +82,7 @@
return module
if type == PY_COMPILED:
return load_compiled(name, filename, file)
- raise ValueError, 'invalid description argument: %r' % (description,)
+ raise ValueError('invalid description argument: %r' % (description,))
def load_dynamic(name, *args, **kwds):
raise ImportError(name)
Modified: pypy/trunk/pypy/lib/itertools.py
==============================================================================
--- pypy/trunk/pypy/lib/itertools.py (original)
+++ pypy/trunk/pypy/lib/itertools.py Mon Jun 1 02:00:54 2009
@@ -357,7 +357,7 @@
self.step = 1
if self.start<0 or (self.stop is not None and self.stop<0
) or self.step<=0:
- raise ValueError, "indices for islice() must be positive"
+ raise ValueError("indices for islice() must be positive")
self.it = iter(iterable)
self.donext = None
self.cnt = 0
Modified: pypy/trunk/pypy/lib/pstats.py
==============================================================================
--- pypy/trunk/pypy/lib/pstats.py (original)
+++ pypy/trunk/pypy/lib/pstats.py Mon Jun 1 02:00:54 2009
@@ -83,7 +83,7 @@
keys = kwds.keys()
keys.sort()
extras = ", ".join(["%s=%s" % (k, kwds[k]) for k in keys])
- raise ValueError, "unrecognized keyword args: %s" % extras
+ raise ValueError("unrecognized keyword args: %s" % extras)
if not len(args):
arg = None
else:
@@ -131,8 +131,8 @@
self.stats = arg.stats
arg.stats = {}
if not self.stats:
- raise TypeError, "Cannot create or construct a %r object from '%r''" % (
- self.__class__, arg)
+ raise TypeError("Cannot create or construct a %r object from '%r''" % (
+ self.__class__, arg))
return
def get_top_level_stats(self):
Modified: pypy/trunk/pypy/lib/stackless.py
==============================================================================
--- pypy/trunk/pypy/lib/stackless.py (original)
+++ pypy/trunk/pypy/lib/stackless.py Mon Jun 1 02:00:54 2009
@@ -101,7 +101,7 @@
getcurrent = staticmethod(getcurrent)
def __reduce__(self):
- raise TypeError, 'pickling is not possible based upon greenlets'
+ raise TypeError('pickling is not possible based upon greenlets')
_maincoro = coroutine()
maingreenlet = greenlet.getcurrent()
@@ -468,16 +468,16 @@
def insert(self):
if self.blocked:
- raise RuntimeError, "You cannot run a blocked tasklet"
+ raise RuntimeError("You cannot run a blocked tasklet")
if not self.alive:
- raise RuntimeError, "You cannot run an unbound(dead) tasklet"
+ raise RuntimeError("You cannot run an unbound(dead) tasklet")
_scheduler_append(self)
def remove(self):
if self.blocked:
- raise RuntimeError, "You cannot remove a blocked tasklet."
+ raise RuntimeError("You cannot remove a blocked tasklet.")
if self is getcurrent():
- raise RuntimeError, "The current tasklet cannot be removed."
+ raise RuntimeError("The current tasklet cannot be removed.")
# not sure if I will revive this " Use t=tasklet().capture()"
_scheduler_remove(self)
Modified: pypy/trunk/pypy/lib/struct.py
==============================================================================
--- pypy/trunk/pypy/lib/struct.py (original)
+++ pypy/trunk/pypy/lib/struct.py Mon Jun 1 02:00:54 2009
@@ -69,7 +69,7 @@
def unpack_float(data,index,size,le):
bytes = [ord(b) for b in data[index:index+size]]
if len(bytes) != size:
- raise StructError,"Not enough data to unpack"
+ raise StructError("Not enough data to unpack")
if max(bytes) == 0:
return 0.0
if le == 'big':
@@ -117,18 +117,18 @@
def pack_signed_int(number,size,le):
if not isinstance(number, (int,long)):
- raise StructError,"argument for i,I,l,L,q,Q,h,H must be integer"
+ raise StructError("argument for i,I,l,L,q,Q,h,H must be integer")
if number > 2**(8*size-1)-1 or number < -1*2**(8*size-1):
- raise OverflowError,"Number:%i too large to convert" % number
+ raise OverflowError("Number:%i too large to convert" % number)
return pack_int(number,size,le)
def pack_unsigned_int(number,size,le):
if not isinstance(number, (int,long)):
- raise StructError,"argument for i,I,l,L,q,Q,h,H must be integer"
+ raise StructError("argument for i,I,l,L,q,Q,h,H must be integer")
if number < 0:
- raise TypeError,"can't convert negative long to unsigned"
+ raise TypeError("can't convert negative long to unsigned")
if number > 2**(8*size)-1:
- raise OverflowError,"Number:%i too large to convert" % number
+ raise OverflowError("Number:%i too large to convert" % number)
return pack_int(number,size,le)
def pack_char(char,size,le):
@@ -248,7 +248,7 @@
try:
format = formatdef[cur]
except KeyError:
- raise StructError,"%s is not a valid format"%cur
+ raise StructError("%s is not a valid format"%cur)
if num != None :
result += num*format['size']
else:
@@ -271,7 +271,7 @@
try:
format = formatdef[cur]
except KeyError:
- raise StructError,"%s is not a valid format"%cur
+ raise StructError("%s is not a valid format"%cur)
if num == None :
num_s = 0
num = 1
@@ -286,7 +286,7 @@
result += [args[0][:num] + '\0'*padding]
args.pop(0)
else:
- raise StructError,"arg for string format not a string"
+ raise StructError("arg for string format not a string")
elif cur == 'p':
if isinstance(args[0], str):
padding = num - len(args[0]) - 1
@@ -300,18 +300,18 @@
result += [chr(255) + args[0][:num-1]]
args.pop(0)
else:
- raise StructError,"arg for string format not a string"
+ raise StructError("arg for string format not a string")
else:
if len(args) < num:
- raise StructError,"insufficient arguments to pack"
+ raise StructError("insufficient arguments to pack")
for var in args[:num]:
result += [format['pack'](var,format['size'],endianness)]
args=args[num:]
num = None
i += 1
if len(args) != 0:
- raise StructError,"too many arguments for pack format"
+ raise StructError("too many arguments for pack format")
return ''.join(result)
def unpack(fmt,data):
@@ -325,7 +325,7 @@
result = []
length= calcsize(fmt)
if length != len (data):
- raise StructError,"unpack str size does not match format"
+ raise StructError("unpack str size does not match format")
while i<len(fmt):
num,i=getNum(fmt,i)
cur = fmt[i]
@@ -333,7 +333,7 @@
try:
format = formatdef[cur]
except KeyError:
- raise StructError,"%s is not a valid format"%cur
+ raise StructError("%s is not a valid format"%cur)
if not num :
num = 1
Modified: pypy/trunk/pypy/lib/xml/dom/domreg.py
==============================================================================
--- pypy/trunk/pypy/lib/xml/dom/domreg.py (original)
+++ pypy/trunk/pypy/lib/xml/dom/domreg.py Mon Jun 1 02:00:54 2009
@@ -77,7 +77,7 @@
if _good_enough(dom, features):
return dom
- raise ImportError,"no suitable DOM implementation found"
+ raise ImportError("no suitable DOM implementation found")
def _parse_feature_string(s):
features = []
@@ -87,7 +87,7 @@
while i < length:
feature = parts[i]
if feature[0] in "0123456789":
- raise ValueError, "bad feature name: %r" % (feature,)
+ raise ValueError("bad feature name: %r" % (feature,))
i = i + 1
version = None
if i < length:
Modified: pypy/trunk/pypy/lib/xml/dom/expatbuilder.py
==============================================================================
--- pypy/trunk/pypy/lib/xml/dom/expatbuilder.py (original)
+++ pypy/trunk/pypy/lib/xml/dom/expatbuilder.py Mon Jun 1 02:00:54 2009
@@ -476,8 +476,7 @@
if val == FILTER_INTERRUPT:
raise ParseEscape
if val not in _ALLOWED_FILTER_RETURNS:
- raise ValueError, \
- "startContainer() returned illegal value: " + repr(val)
+ raise ValueError("startContainer() returned illegal value: " + repr(val))
return val
else:
return FILTER_ACCEPT
@@ -496,8 +495,7 @@
# node is handled by the caller
return FILTER_REJECT
if val not in _ALLOWED_FILTER_RETURNS:
- raise ValueError, \
- "acceptNode() returned illegal value: " + repr(val)
+ raise ValueError("acceptNode() returned illegal value: " + repr(val))
return val
else:
return FILTER_ACCEPT
Modified: pypy/trunk/pypy/lib/xml/dom/minidom.py
==============================================================================
--- pypy/trunk/pypy/lib/xml/dom/minidom.py (original)
+++ pypy/trunk/pypy/lib/xml/dom/minidom.py Mon Jun 1 02:00:54 2009
@@ -538,7 +538,7 @@
node.value = value
else:
if not isinstance(value, Attr):
- raise TypeError, "value must be a string or Attr object"
+ raise TypeError("value must be a string or Attr object")
node = value
self.setNamedItem(node)
@@ -1173,7 +1173,7 @@
else:
node = self.getNamedItem(name_or_tuple)
if node is None:
- raise KeyError, name_or_tuple
+ raise KeyError(name_or_tuple)
return node
def item(self, index):
@@ -1603,7 +1603,7 @@
def createTextNode(self, data):
if not isinstance(data, StringTypes):
- raise TypeError, "node contents must be a string"
+ raise TypeError("node contents must be a string")
t = Text()
t.data = data
t.ownerDocument = self
@@ -1611,7 +1611,7 @@
def createCDATASection(self, data):
if not isinstance(data, StringTypes):
- raise TypeError, "node contents must be a string"
+ raise TypeError("node contents must be a string")
c = CDATASection()
c.data = data
c.ownerDocument = self
Modified: pypy/trunk/pypy/lib/xml/sax/xmlreader.py
==============================================================================
--- pypy/trunk/pypy/lib/xml/sax/xmlreader.py (original)
+++ pypy/trunk/pypy/lib/xml/sax/xmlreader.py Mon Jun 1 02:00:54 2009
@@ -295,12 +295,12 @@
def getNameByQName(self, name):
if not self._attrs.has_key(name):
- raise KeyError, name
+ raise KeyError(name)
return name
def getQNameByName(self, name):
if not self._attrs.has_key(name):
- raise KeyError, name
+ raise KeyError(name)
return name
def getNames(self):
@@ -353,14 +353,14 @@
if qname == name:
return self._attrs[nsname]
- raise KeyError, name
+ raise KeyError(name)
def getNameByQName(self, name):
for (nsname, qname) in self._qnames.items():
if qname == name:
return nsname
- raise KeyError, name
+ raise KeyError(name)
def getQNameByName(self, name):
return self._qnames[name]
Modified: pypy/trunk/pypy/module/__builtin__/app_functional.py
==============================================================================
--- pypy/trunk/pypy/module/__builtin__/app_functional.py (original)
+++ pypy/trunk/pypy/module/__builtin__/app_functional.py Mon Jun 1 02:00:54 2009
@@ -38,7 +38,7 @@
"""
if len(collections) == 0:
- raise TypeError, "map() requires at least one sequence"
+ raise TypeError("map() requires at least one sequence")
if len(collections) == 1:
#it's the most common case, so make it faster
@@ -138,7 +138,7 @@
try:
initial = seqiter.next()
except StopIteration:
- raise TypeError, "reduce() of empty sequence with no initial value"
+ raise TypeError("reduce() of empty sequence with no initial value")
while 1:
try:
arg = seqiter.next()
@@ -181,7 +181,7 @@
raise TypeError('range() integer step argument expected, got %s' % type(step))
if step == 0:
- raise ValueError, 'range() arg 3 must not be zero'
+ raise ValueError('range() arg 3 must not be zero')
elif step > 0:
if stop <= start: # no work for us
@@ -221,10 +221,10 @@
def min_max(comp, funcname, *arr, **kwargs):
key = kwargs.pop("key", _identity)
if len(kwargs):
- raise TypeError, '%s() got an unexpected keyword argument' % funcname
+ raise TypeError('%s() got an unexpected keyword argument' % funcname)
if not arr:
- raise TypeError, '%s() takes at least one argument' % funcname
+ raise TypeError('%s() takes at least one argument' % funcname)
if len(arr) == 1:
arr = arr[0]
@@ -233,7 +233,7 @@
try:
min_max_val = iterator.next()
except StopIteration:
- raise ValueError, '%s() arg is an empty sequence' % funcname
+ raise ValueError('%s() arg is an empty sequence' % funcname)
keyed_min_max_val = key(min_max_val)
Modified: pypy/trunk/pypy/module/__builtin__/app_inspect.py
==============================================================================
--- pypy/trunk/pypy/module/__builtin__/app_inspect.py (original)
+++ pypy/trunk/pypy/module/__builtin__/app_inspect.py Mon Jun 1 02:00:54 2009
@@ -24,12 +24,12 @@
if len(obj) == 0:
return _caller_locals()
elif len(obj) != 1:
- raise TypeError, "vars() takes at most 1 argument."
+ raise TypeError("vars() takes at most 1 argument.")
else:
try:
return obj[0].__dict__
except AttributeError:
- raise TypeError, "vars() argument must have __dict__ attribute"
+ raise TypeError("vars() argument must have __dict__ attribute")
# Replaced by the interp-level helper space.callable():
##def callable(ob):
Modified: pypy/trunk/pypy/module/__builtin__/test/test_classobj.py
==============================================================================
--- pypy/trunk/pypy/module/__builtin__/test/test_classobj.py (original)
+++ pypy/trunk/pypy/module/__builtin__/test/test_classobj.py Mon Jun 1 02:00:54 2009
@@ -670,7 +670,7 @@
def test_catch_attributeerror_of_descriptor(self):
def booh(self):
- raise this_exception, "booh"
+ raise this_exception("booh")
class E:
__eq__ = property(booh)
Modified: pypy/trunk/pypy/module/__builtin__/test/test_descriptor.py
==============================================================================
--- pypy/trunk/pypy/module/__builtin__/test/test_descriptor.py (original)
+++ pypy/trunk/pypy/module/__builtin__/test/test_descriptor.py Mon Jun 1 02:00:54 2009
@@ -300,4 +300,4 @@
except ZeroDivisionError:
pass
else:
- raise Exception, "expected ZeroDivisionError from bad property"
+ raise Exception("expected ZeroDivisionError from bad property")
Modified: pypy/trunk/pypy/module/_sre/app_sre.py
==============================================================================
--- pypy/trunk/pypy/module/_sre/app_sre.py (original)
+++ pypy/trunk/pypy/module/_sre/app_sre.py Mon Jun 1 02:00:54 2009
@@ -159,10 +159,10 @@
return SRE_Scanner(self, string, start, end)
def __copy__(self):
- raise TypeError, "cannot copy this pattern object"
+ raise TypeError("cannot copy this pattern object")
def __deepcopy__(self):
- raise TypeError, "cannot copy this pattern object"
+ raise TypeError("cannot copy this pattern object")
class SRE_Scanner(object):
@@ -285,7 +285,7 @@
return tuple(grouplist)
def __copy__():
- raise TypeError, "cannot copy this pattern object"
+ raise TypeError("cannot copy this pattern object")
def __deepcopy__():
- raise TypeError, "cannot copy this pattern object"
+ raise TypeError("cannot copy this pattern object")
Modified: pypy/trunk/pypy/module/_stackless/test/test_greenlet.py
==============================================================================
--- pypy/trunk/pypy/module/_stackless/test/test_greenlet.py (original)
+++ pypy/trunk/pypy/module/_stackless/test/test_greenlet.py Mon Jun 1 02:00:54 2009
@@ -453,7 +453,7 @@
g = greenlet.getcurrent()
while not isinstance(g, genlet):
if g is None:
- raise RuntimeError, 'yield outside a genlet'
+ raise RuntimeError('yield outside a genlet')
g = g.parent
g.parent.switch(value)
Modified: pypy/trunk/pypy/module/clr/app_clr.py
==============================================================================
--- pypy/trunk/pypy/module/clr/app_clr.py (original)
+++ pypy/trunk/pypy/module/clr/app_clr.py Mon Jun 1 02:00:54 2009
@@ -39,9 +39,9 @@
self.im_name = im_name
def __raise_TypeError(self, thing):
- raise TypeError, 'unbound method %s() must be called with %s ' \
+ raise TypeError('unbound method %s() must be called with %s ' \
'instance as first argument (got %s instead)' % \
- (self.im_name, self.im_class.__cliclass__, thing)
+ (self.im_name, self.im_class.__cliclass__, thing))
def __call__(self, *args):
if len(args) == 0:
@@ -116,7 +116,7 @@
try:
return clr.load_cli_class(cls.__assemblyname__, namespace, instance_class)
except ImportError:
- raise TypeError, "Cannot load type %s.%s" % (namespace, instance_class)
+ raise TypeError("Cannot load type %s.%s" % (namespace, instance_class))
class MetaCliClassWrapper(type):
def __setattr__(cls, name, value):
Modified: pypy/trunk/pypy/module/fcntl/app_fcntl.py
==============================================================================
--- pypy/trunk/pypy/module/fcntl/app_fcntl.py (original)
+++ pypy/trunk/pypy/module/fcntl/app_fcntl.py Mon Jun 1 02:00:54 2009
@@ -5,7 +5,7 @@
elif isinstance(f, (int, long)):
return f
else:
- raise TypeError, "argument must be an int, or have a fileno() method."
+ raise TypeError("argument must be an int, or have a fileno() method.")
__doc__ = """This module performs file control and I/O control on file
descriptors. It is an interface to the fcntl() and ioctl() Unix
Modified: pypy/trunk/pypy/module/operator/app_operator.py
==============================================================================
--- pypy/trunk/pypy/module/operator/app_operator.py (original)
+++ pypy/trunk/pypy/module/operator/app_operator.py Mon Jun 1 02:00:54 2009
@@ -34,7 +34,7 @@
if x == b:
return index
index += 1
- raise ValueError, 'sequence.index(x): x not in sequence'
+ raise ValueError('sequence.index(x): x not in sequence')
# XXX the following is approximative
def isMappingType(obj,):
@@ -53,9 +53,9 @@
def repeat(obj, num):
'repeat(a, b) -- Return a * b, where a is a sequence, and b is an integer.'
if not isinstance(num, (int, long)):
- raise TypeError, 'an integer is required'
+ raise TypeError('an integer is required')
if not isSequenceType(obj):
- raise TypeError, "non-sequence object can't be repeated"
+ raise TypeError("non-sequence object can't be repeated")
return obj * num
Modified: pypy/trunk/pypy/module/posix/app_posix.py
==============================================================================
--- pypy/trunk/pypy/module/posix/app_posix.py (original)
+++ pypy/trunk/pypy/module/posix/app_posix.py Mon Jun 1 02:00:54 2009
@@ -151,7 +151,7 @@
except Exception, e:
try_close(write_end)
try_close(read_end)
- raise Exception, e # bare 'raise' does not work here :-(
+ raise Exception(e) # bare 'raise' does not work here :-(
else:
# Windows implementations
Modified: pypy/trunk/pypy/module/sys/app.py
==============================================================================
--- pypy/trunk/pypy/module/sys/app.py (original)
+++ pypy/trunk/pypy/module/sys/app.py Mon Jun 1 02:00:54 2009
@@ -19,7 +19,7 @@
# note that we cannot use SystemExit(exitcode) here.
# The comma version leads to an extra de-tupelizing
# in normalize_exception, which is exactly like CPython's.
- raise SystemExit, exitcode
+ raise SystemExit(exitcode)
def exitfunc():
"""Placeholder for sys.exitfunc(), which is called when PyPy exits."""
Modified: pypy/trunk/pypy/module/sys/test/test_sysmodule.py
==============================================================================
--- pypy/trunk/pypy/module/sys/test/test_sysmodule.py (original)
+++ pypy/trunk/pypy/module/sys/test/test_sysmodule.py Mon Jun 1 02:00:54 2009
@@ -73,7 +73,7 @@
etype, val, tb = sys.exc_info()
assert isinstance(val, etype)
else:
- raise AssertionError, "ZeroDivisionError not caught"
+ raise AssertionError("ZeroDivisionError not caught")
def test_io(self):
import sys
@@ -174,7 +174,7 @@
def clear():
try:
- raise ValueError, 42
+ raise ValueError(42)
except ValueError, exc:
clear_check(exc)
@@ -184,7 +184,7 @@
# Verify that a frame currently handling an exception is
# unaffected by calling exc_clear in a nested frame.
try:
- raise ValueError, 13
+ raise ValueError(13)
except ValueError, exc:
typ1, value1, traceback1 = sys.exc_info()
clear()
@@ -207,9 +207,9 @@
except SystemExit, exc:
assert exc.code == 0
except:
- raise AssertionError, "wrong exception"
+ raise AssertionError("wrong exception")
else:
- raise AssertionError, "no exception"
+ raise AssertionError("no exception")
# call with tuple argument with one entry
# entry will be unpacked
@@ -218,9 +218,9 @@
except SystemExit, exc:
assert exc.code == 42
except:
- raise AssertionError, "wrong exception"
+ raise AssertionError("wrong exception")
else:
- raise AssertionError, "no exception"
+ raise AssertionError("no exception")
# call with integer argument
try:
@@ -228,9 +228,9 @@
except SystemExit, exc:
assert exc.code == 42
except:
- raise AssertionError, "wrong exception"
+ raise AssertionError("wrong exception")
else:
- raise AssertionError, "no exception"
+ raise AssertionError("no exception")
# call with string argument
try:
@@ -238,9 +238,9 @@
except SystemExit, exc:
assert exc.code == "exit"
except:
- raise AssertionError, "wrong exception"
+ raise AssertionError("wrong exception")
else:
- raise AssertionError, "no exception"
+ raise AssertionError("no exception")
# call with tuple argument with two entries
try:
@@ -248,9 +248,9 @@
except SystemExit, exc:
assert exc.code == (17, 23)
except:
- raise AssertionError, "wrong exception"
+ raise AssertionError("wrong exception")
else:
- raise AssertionError, "no exception"
+ raise AssertionError("no exception")
def test_getdefaultencoding(self):
raises(TypeError, sys.getdefaultencoding, 42)
Modified: pypy/trunk/pypy/module/unicodedata/interp_ucd.py
==============================================================================
--- pypy/trunk/pypy/module/unicodedata/interp_ucd.py (original)
+++ pypy/trunk/pypy/module/unicodedata/interp_ucd.py Mon Jun 1 02:00:54 2009
@@ -147,7 +147,7 @@
def normalize(self, space, form, w_unistr):
if not space.is_true(space.isinstance(w_unistr, space.w_unicode)):
- raise TypeError, 'argument 2 must be unicode'
+ raise TypeError('argument 2 must be unicode')
if form == 'NFC':
composed = True
decomposition = self._canon_decomposition
Modified: pypy/trunk/pypy/module/unicodedata/unicodedb_4_1_0.py
==============================================================================
--- pypy/trunk/pypy/module/unicodedata/unicodedb_4_1_0.py (original)
+++ pypy/trunk/pypy/module/unicodedata/unicodedb_4_1_0.py Mon Jun 1 02:00:54 2009
@@ -37,7 +37,7 @@
charnode = left
else:
charnode = right
- raise KeyError, name
+ raise KeyError(name)
def name_of_node(charnode):
res = []
@@ -85069,7 +85069,7 @@
if code == 917505: res = 6779
if 917536 <= code <= 917631: res = _charnames_917536[code-917536]
if 917760 <= code <= 917999: res = _charnames_917760[code-917760]
- if res == -1: raise KeyError, code
+ if res == -1: raise KeyError(code)
return name_of_node(res)
# the following dictionary is used by modules that take this as a base
Modified: pypy/trunk/pypy/objspace/descroperation.py
==============================================================================
--- pypy/trunk/pypy/objspace/descroperation.py (original)
+++ pypy/trunk/pypy/objspace/descroperation.py Mon Jun 1 02:00:54 2009
@@ -721,5 +721,5 @@
elif _name not in ['is_', 'id','type','issubtype',
# not really to be defined in DescrOperation
'ord', 'unichr', 'unicode']:
- raise Exception, "missing def for operation %s" % _name
+ raise Exception("missing def for operation %s" % _name)
Modified: pypy/trunk/pypy/objspace/flow/flowcontext.py
==============================================================================
--- pypy/trunk/pypy/objspace/flow/flowcontext.py (original)
+++ pypy/trunk/pypy/objspace/flow/flowcontext.py Mon Jun 1 02:00:54 2009
@@ -76,7 +76,7 @@
pass
def guessbool(self, ec, w_condition, **kwds):
- raise AssertionError, "cannot guessbool(%s)" % (w_condition,)
+ raise AssertionError("cannot guessbool(%s)" % (w_condition,))
class BlockRecorder(Recorder):
@@ -179,7 +179,7 @@
# Concrete mode is used to precompute lazily-initialized caches,
# when we don't want this precomputation to show up on the flow graph.
def append(self, operation):
- raise AssertionError, "concrete mode: cannot perform %s" % operation
+ raise AssertionError("concrete mode: cannot perform %s" % operation)
# ____________________________________________________________
Modified: pypy/trunk/pypy/objspace/flow/objspace.py
==============================================================================
--- pypy/trunk/pypy/objspace/flow/objspace.py (original)
+++ pypy/trunk/pypy/objspace/flow/objspace.py Mon Jun 1 02:00:54 2009
@@ -197,7 +197,7 @@
try:
check_class = self.unwrap(w_check_class)
except UnwrapException:
- raise Exception, "non-constant except guard"
+ raise Exception("non-constant except guard")
if not isinstance(check_class, tuple):
# the simple case
return ObjSpace.exception_match(self, w_exc_type, w_check_class)
@@ -221,7 +221,7 @@
"""
"""
if func.func_doc and func.func_doc.lstrip().startswith('NOT_RPYTHON'):
- raise Exception, "%r is tagged as NOT_RPYTHON" % (func,)
+ raise Exception("%r is tagged as NOT_RPYTHON" % (func,))
code = func.func_code
if code.co_flags & 32:
# generator
@@ -267,8 +267,8 @@
unwrapped = self.unwrap(w_tuple)
result = tuple([Constant(x) for x in unwrapped])
if expected_length is not None and len(result) != expected_length:
- raise ValueError, "got a tuple of length %d instead of %d" % (
- len(result), expected_length)
+ raise ValueError("got a tuple of length %d instead of %d" % (
+ len(result), expected_length))
return result
def unpackiterable(self, w_iterable, expected_length=None):
@@ -278,7 +278,7 @@
raise ValueError
return [self.wrap(x) for x in l]
if isinstance(w_iterable, Variable) and expected_length is None:
- raise UnwrapException, ("cannot unpack a Variable iterable"
+ raise UnwrapException("cannot unpack a Variable iterable"
"without knowing its length")
elif expected_length is not None:
w_len = self.len(w_iterable)
@@ -497,7 +497,7 @@
for name in names.split():
lis = implicit_exceptions.setdefault(name, [])
if exc in lis:
- raise ValueError, "your list is causing duplication!"
+ raise ValueError("your list is causing duplication!")
lis.append(exc)
assert exc in op_appendices
@@ -669,7 +669,7 @@
ec = self.getexecutioncontext()
if not (ec and w_obj is ec.w_globals):
return self.regular_setitem(w_obj, w_key, w_val)
- raise SyntaxError, "attempt to modify global attribute %r in %r" % (w_key, ec.graph.func)
+ raise SyntaxError("attempt to modify global attribute %r in %r" % (w_key, ec.graph.func))
FlowObjSpace.regular_setitem = FlowObjSpace.setitem
FlowObjSpace.setitem = setitem
Modified: pypy/trunk/pypy/objspace/flow/specialcase.py
==============================================================================
--- pypy/trunk/pypy/objspace/flow/specialcase.py (original)
+++ pypy/trunk/pypy/objspace/flow/specialcase.py Mon Jun 1 02:00:54 2009
@@ -21,7 +21,7 @@
if not isinstance(w_loc, Constant):
# import * in a function gives us the locals as Variable
# we always forbid it as a SyntaxError
- raise SyntaxError, "RPython: import * is not allowed in functions"
+ raise SyntaxError("RPython: import * is not allowed in functions")
if space.do_imports_immediately:
name, glob, loc, frm = (space.unwrap(w_name), space.unwrap(w_glob),
space.unwrap(w_loc), space.unwrap(w_frm))
@@ -45,8 +45,8 @@
elif opname == 'getattr' and len(args_w) == 3:
return space.do_operation('simple_call', Constant(getattr), *args_w)
else:
- raise Exception, "should call %r with exactly %d arguments" % (
- fn, Arity[opname])
+ raise Exception("should call %r with exactly %d arguments" % (
+ fn, Arity[opname]))
if space.config.translation.builtins_can_raise_exceptions:
# in this mode, avoid constant folding and raise an implicit Exception
w_result = space.do_operation(opname, *args_w)
Modified: pypy/trunk/pypy/objspace/flow/test/test_objspace.py
==============================================================================
--- pypy/trunk/pypy/objspace/flow/test/test_objspace.py (original)
+++ pypy/trunk/pypy/objspace/flow/test/test_objspace.py Mon Jun 1 02:00:54 2009
@@ -378,7 +378,7 @@
#__________________________________________________________
def raise2(msg):
- raise IndexError, msg
+ raise IndexError(msg)
def test_raise2(self):
x = self.codetest(self.raise2)
Modified: pypy/trunk/pypy/objspace/std/boolobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/boolobject.py (original)
+++ pypy/trunk/pypy/objspace/std/boolobject.py Mon Jun 1 02:00:54 2009
@@ -11,7 +11,7 @@
w_self.boolval = not not boolval
def __nonzero__(w_self):
- raise Exception, "you cannot do that, you must use space.is_true()"
+ raise Exception("you cannot do that, you must use space.is_true()")
def __repr__(w_self):
""" representation for debugging purposes """
Modified: pypy/trunk/pypy/objspace/std/model.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/model.py (original)
+++ pypy/trunk/pypy/objspace/std/model.py Mon Jun 1 02:00:54 2009
@@ -290,7 +290,7 @@
return '<%s>' % s
def unwrap(w_self, space):
- raise UnwrapError, 'cannot unwrap %r' % (w_self,)
+ raise UnwrapError('cannot unwrap %r' % (w_self,))
class UnwrapError(Exception):
pass
Modified: pypy/trunk/pypy/objspace/std/mro.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/mro.py (original)
+++ pypy/trunk/pypy/objspace/std/mro.py Mon Jun 1 02:00:54 2009
@@ -47,7 +47,7 @@
cycle.append(candidate)
cycle.reverse()
names = [cls.__name__ for cls in cycle]
- raise TypeError, "Cycle among base classes: " + ' < '.join(names)
+ raise TypeError("Cycle among base classes: " + ' < '.join(names))
def mronames(cls):
Modified: pypy/trunk/pypy/objspace/std/multimethod.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/multimethod.py (original)
+++ pypy/trunk/pypy/objspace/std/multimethod.py Mon Jun 1 02:00:54 2009
@@ -41,7 +41,7 @@
MultiMethod-maker dispatching on exactly 'arity' arguments.
"""
if arity < 1:
- raise ValueError, "multimethods cannot dispatch on nothing"
+ raise ValueError("multimethods cannot dispatch on nothing")
self.arity = arity
self.root_class = root_class
self.dispatch_tree = {}
Modified: pypy/trunk/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/objspace.py (original)
+++ pypy/trunk/pypy/objspace/std/objspace.py Mon Jun 1 02:00:54 2009
@@ -205,7 +205,7 @@
w_result = getattr(f, attr)(w_1, w_2)
break
else:
- raise BytecodeCorruption, "bad COMPARE_OP oparg"
+ raise BytecodeCorruption("bad COMPARE_OP oparg")
f.pushvalue(w_result)
if self.config.objspace.std.logspaceoptypes:
@@ -463,9 +463,9 @@
if x is None:
return self.w_None
if isinstance(x, W_Object):
- raise TypeError, "attempt to wrap already wrapped object: %s"%(x,)
+ raise TypeError("attempt to wrap already wrapped object: %s"%(x,))
if isinstance(x, OperationError):
- raise TypeError, ("attempt to wrap already wrapped exception: %s"%
+ raise TypeError("attempt to wrap already wrapped exception: %s"%
(x,))
if isinstance(x, int):
if isinstance(x, bool):
@@ -557,7 +557,7 @@
return w_obj
if isinstance(w_obj, W_Object):
return w_obj.unwrap(self)
- raise UnwrapError, "cannot unwrap: %r" % w_obj
+ raise UnwrapError("cannot unwrap: %r" % w_obj)
def newint(self, intval):
# this time-critical and circular-imports-funny method was stored
Modified: pypy/trunk/pypy/objspace/std/register_all.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/register_all.py (original)
+++ pypy/trunk/pypy/objspace/std/register_all.py Mon Jun 1 02:00:54 2009
@@ -37,9 +37,8 @@
if isinstance(x, StdTypeDef):
icls = x.any
if icls is None:
- raise ValueError, \
- "no W_%s or W_%sObject for the definition of %s" % (
- i, i, name)
+ raise ValueError("no W_%s or W_%sObject for the definition of %s" % (
+ i, i, name))
l.append(icls)
#XXX trying to be too clever at the moment for userobject.SpecialMethod
@@ -75,7 +74,7 @@
return getattr(objecttype, funcname)
except AttributeError:
pass
- raise NameError, ("trying hard but not finding a multimethod named %s" %
+ raise NameError("trying hard but not finding a multimethod named %s" %
funcname)
Modified: pypy/trunk/pypy/objspace/std/stdtypedef.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/stdtypedef.py (original)
+++ pypy/trunk/pypy/objspace/std/stdtypedef.py Mon Jun 1 02:00:54 2009
@@ -157,7 +157,7 @@
if multimethod.extras.get('w_varargs', False):
wrapper_arglist.append('w_args')
if multimethod.extras.get('keywords', False):
- raise Exception, "no longer supported, use __args__"
+ raise Exception("no longer supported, use __args__")
if multimethod.extras.get('general__args__', False):
wrapper_arglist.append('__args__')
wrapper_arglist += multimethod.extras.get('extra_args', ())
Modified: pypy/trunk/pypy/objspace/std/strutil.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/strutil.py (original)
+++ pypy/trunk/pypy/objspace/std/strutil.py Mon Jun 1 02:00:54 2009
@@ -33,9 +33,9 @@
def error(self):
if self.literal:
- raise ParseStringError, 'invalid literal for %s(): %s' % (self.fname, self.literal)
+ raise ParseStringError('invalid literal for %s(): %s' % (self.fname, self.literal))
else:
- raise ParseStringError, 'empty string for %s()' % (self.fname,)
+ raise ParseStringError('empty string for %s()' % (self.fname,))
def __init__(self, s, literal, base, fname):
self.literal = literal
@@ -56,7 +56,7 @@
else:
base = 10
elif base < 2 or base > 36:
- raise ParseStringError, "%s() base must be >= 2 and <= 36" % (fname,)
+ raise ParseStringError("%s() base must be >= 2 and <= 36" % (fname,))
self.base = base
if not s:
Modified: pypy/trunk/pypy/objspace/std/test/test_dictproxy.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/test/test_dictproxy.py (original)
+++ pypy/trunk/pypy/objspace/std/test/test_dictproxy.py Mon Jun 1 02:00:54 2009
@@ -15,7 +15,7 @@
except:
pass
else:
- raise AssertionError, 'this should not have been writable'
+ raise AssertionError('this should not have been writable')
def test_dictproxyeq(self):
class a(object):
Modified: pypy/trunk/pypy/objspace/std/test/test_intobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/test/test_intobject.py (original)
+++ pypy/trunk/pypy/objspace/std/test/test_intobject.py Mon Jun 1 02:00:54 2009
@@ -23,7 +23,7 @@
""" make sure that the expected exception occours, and unwrap it """
try:
res = func(*args, **kwds)
- raise Exception, "should have failed but returned '%s'!" %repr(res)
+ raise Exception("should have failed but returned '%s'!" %repr(res))
except FailedToImplement, arg:
return arg.w_type
Modified: pypy/trunk/pypy/objspace/std/test/test_typeobject.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/test/test_typeobject.py (original)
+++ pypy/trunk/pypy/objspace/std/test/test_typeobject.py Mon Jun 1 02:00:54 2009
@@ -249,7 +249,7 @@
return super(WorkOnce, self).__new__(WorkOnce, name, bases, ns)
def mro(instance):
if instance.flag > 0:
- raise RuntimeError, "bozo"
+ raise RuntimeError("bozo")
else:
instance.flag += 1
return type.mro(instance)
@@ -316,7 +316,7 @@
except TypeError:
pass
else:
- raise TestFailed, "didn't catch MRO conflict"
+ raise TestFailed("didn't catch MRO conflict")
def test_mutable_bases_versus_nonheap_types(self):
class A(int):
@@ -450,7 +450,7 @@
except TypeError:
pass
else:
- raise AssertionError, "this multiple inheritance should fail"
+ raise AssertionError("this multiple inheritance should fail")
def test_outer_metaclass(self):
class OuterMetaClass(type):
@@ -520,7 +520,7 @@
try:
assert NoDoc.__doc__ == None
except AttributeError:
- raise AssertionError, "__doc__ missing!"
+ raise AssertionError("__doc__ missing!")
def test_explicitdoc(self):
class ExplicitDoc(object):
@@ -547,7 +547,7 @@
# we always raise AttributeError.
pass
else:
- raise AssertionError, '__doc__ should not be writable'
+ raise AssertionError('__doc__ should not be writable')
assert ImmutableDoc.__doc__ == 'foo'
Modified: pypy/trunk/pypy/objspace/test/test_descroperation.py
==============================================================================
--- pypy/trunk/pypy/objspace/test/test_descroperation.py (original)
+++ pypy/trunk/pypy/objspace/test/test_descroperation.py Mon Jun 1 02:00:54 2009
@@ -129,7 +129,7 @@
def __setslice__(self, start, stop, sequence):
ops.append((start, stop, sequence))
def __setitem__(self, key, value):
- raise AssertionError, key
+ raise AssertionError(key)
def __len__(self):
return 100
@@ -154,7 +154,7 @@
def __delslice__(self, start, stop):
ops.append((start, stop))
def __delitem__(self, key):
- raise AssertionError, key
+ raise AssertionError(key)
def __len__(self):
return 100
Modified: pypy/trunk/pypy/rlib/objectmodel.py
==============================================================================
--- pypy/trunk/pypy/rlib/objectmodel.py (original)
+++ pypy/trunk/pypy/rlib/objectmodel.py Mon Jun 1 02:00:54 2009
@@ -203,7 +203,7 @@
" %r" % (vobj.concretetype,))
def hlinvoke(repr, llcallable, *args):
- raise TypeError, "hlinvoke is meant to be rtyped and not called direclty"
+ raise TypeError("hlinvoke is meant to be rtyped and not called direclty")
def invoke_around_extcall(before, after):
"""Call before() before any external function call, and after() after.
Modified: pypy/trunk/pypy/rlib/rarithmetic.py
==============================================================================
--- pypy/trunk/pypy/rlib/rarithmetic.py (original)
+++ pypy/trunk/pypy/rlib/rarithmetic.py Mon Jun 1 02:00:54 2009
@@ -99,7 +99,7 @@
# raise OverflowError if the operation did overflow
assert not isinstance(r, r_uint), "unexpected ovf check on unsigned"
if type(r) is long:
- raise OverflowError, "signed integer expression did overflow"
+ raise OverflowError("signed integer expression did overflow")
return r
def _local_ovfcheck(r):
@@ -107,7 +107,7 @@
# in a context where no primitiveoperator is involved.
assert not isinstance(r, r_uint), "unexpected ovf check on unsigned"
if isinstance(r, long):
- raise OverflowError, "signed integer expression did overflow"
+ raise OverflowError("signed integer expression did overflow")
return r
def ovfcheck_lshift(a, b):
Modified: pypy/trunk/pypy/rlib/rzipfile.py
==============================================================================
--- pypy/trunk/pypy/rlib/rzipfile.py (original)
+++ pypy/trunk/pypy/rlib/rzipfile.py Mon Jun 1 02:00:54 2009
@@ -165,7 +165,7 @@
def _GetContents(self, fp):
endrec = _EndRecData(fp)
if not endrec:
- raise BadZipfile, "File is not a zip file"
+ raise BadZipfile("File is not a zip file")
size_cd = endrec.stuff[5] # bytes in central directory
offset_cd = endrec.stuff[6] # offset of central directory
self.comment = endrec.comment
@@ -178,7 +178,7 @@
centdir = fp.read(46)
total = total + 46
if centdir[0:4] != stringCentralDir:
- raise BadZipfile, "Bad magic number for central directory"
+ raise BadZipfile("Bad magic number for central directory")
centdir = runpack(structCentralDir, centdir)
filename = fp.read(centdir[_CD_FILENAME_LENGTH])
# Create ZipInfo instance to store file information
@@ -206,7 +206,7 @@
fp.seek(data.header_offset, 0)
fheader = fp.read(30)
if fheader[0:4] != stringFileHeader:
- raise BadZipfile, "Bad magic number for file header"
+ raise BadZipfile("Bad magic number for file header")
fheader = runpack(structFileHeader, fheader)
# file_offset is computed here, since the extra field for
# the central directory and for the local file header
@@ -217,9 +217,8 @@
+ fheader[_FH_EXTRA_FIELD_LENGTH])
fname = fp.read(fheader[_FH_FILENAME_LENGTH])
if fname != data.orig_filename:
- raise RuntimeError, \
- 'File name in directory "%s" and header "%s" differ.' % (
- data.orig_filename, fname)
+ raise RuntimeError('File name in directory "%s" and header "%s" differ.' % (
+ data.orig_filename, fname))
fp.seek(self.start_dir, 0)
def getinfo(self, filename):
@@ -245,15 +244,13 @@
finally:
rzlib.inflateEnd(stream)
elif zinfo.compress_type == ZIP_DEFLATED:
- raise BadZipfile, \
- "Cannot decompress file, zlib not installed"
+ raise BadZipfile("Cannot decompress file, zlib not installed")
else:
- raise BadZipfile, \
- "Unsupported compression method %d for file %s" % \
- (zinfo.compress_type, filename)
+ raise BadZipfile("Unsupported compression method %d for file %s" % \
+ (zinfo.compress_type, filename))
crc = crc32(bytes)
if crc != zinfo.CRC:
- raise BadZipfile, "Bad CRC-32 for file %s" % filename
+ raise BadZipfile("Bad CRC-32 for file %s" % filename)
return bytes
def close(self):
Modified: pypy/trunk/pypy/rlib/test/test_streamio.py
==============================================================================
--- pypy/trunk/pypy/rlib/test/test_streamio.py (original)
+++ pypy/trunk/pypy/rlib/test/test_streamio.py Mon Jun 1 02:00:54 2009
@@ -89,7 +89,7 @@
elif whence == 2:
offset += len(self.buf)
else:
- raise ValueError, "whence should be 0, 1 or 2"
+ raise ValueError("whence should be 0, 1 or 2")
if offset < 0:
offset = 0
self.pos = offset
Modified: pypy/trunk/pypy/rpython/callparse.py
==============================================================================
--- pypy/trunk/pypy/rpython/callparse.py (original)
+++ pypy/trunk/pypy/rpython/callparse.py Mon Jun 1 02:00:54 2009
@@ -54,7 +54,7 @@
try:
holders = arguments.match_signature(signature, defs_h)
except ArgErr, e:
- raise TyperError, "signature mismatch: %s" % e.getmsg(graph.name)
+ raise TyperError("signature mismatch: %s" % e.getmsg(graph.name))
assert len(holders) == len(rinputs), "argument parsing mismatch"
vlist = []
@@ -168,7 +168,7 @@
return NewTupleHolder(items)
def newdict(self):
- raise CallPatternTooComplex, "'**' argument"
+ raise CallPatternTooComplex("'**' argument")
def unpackiterable(self, it, expected_length=None):
if it.is_tuple():
@@ -177,7 +177,7 @@
expected_length != len(items)):
raise ValueError
return list(items)
- raise CallPatternTooComplex, "'*' argument must be a tuple"
+ raise CallPatternTooComplex("'*' argument must be a tuple")
def is_w(self, one, other):
return one is other
Modified: pypy/trunk/pypy/rpython/llinterp.py
==============================================================================
--- pypy/trunk/pypy/rpython/llinterp.py (original)
+++ pypy/trunk/pypy/rpython/llinterp.py Mon Jun 1 02:00:54 2009
@@ -155,7 +155,7 @@
etype = frame.op_direct_call(exdata.fn_type_of_exc_inst, evalue)
if etype == klass:
return cls
- raise ValueError, "couldn't match exception"
+ raise ValueError("couldn't match exception")
def get_transformed_exc_data(self, graph):
if hasattr(graph, 'exceptiontransformed'):
Modified: pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py (original)
+++ pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py Mon Jun 1 02:00:54 2009
@@ -118,7 +118,7 @@
def _malloc(cls, n=None):
if not isinstance(n, int):
- raise TypeError, "array length must be an int"
+ raise TypeError("array length must be an int")
biggercls = get_ctypes_array_of_size(A, n)
bigarray = biggercls()
if hasattr(bigarray, 'length'):
Modified: pypy/trunk/pypy/rpython/lltypesystem/lltype.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/lltype.py (original)
+++ pypy/trunk/pypy/rpython/lltypesystem/lltype.py Mon Jun 1 02:00:54 2009
@@ -145,7 +145,7 @@
_adtmeths = {}
def _inline_is_varsize(self, last):
- raise TypeError, "%r cannot be inlined in structure" % self
+ raise TypeError("%r cannot be inlined in structure" % self)
def _install_extras(self, adtmeths={}, hints={}):
self._adtmeths = frozendict(adtmeths)
@@ -177,7 +177,7 @@
self._arrayfld = None
for name, typ in fields:
if name.startswith('_'):
- raise NameError, ("%s: field name %r should not start with "
+ raise NameError("%s: field name %r should not start with "
"an underscore" % (self._name, name,))
names.append(name)
if name in flds:
@@ -235,8 +235,8 @@
def _nofield(self, name):
- raise AttributeError, 'struct %s has no field %r' % (self._name,
- name)
+ raise AttributeError('struct %s has no field %r' % (self._name,
+ name))
def _names_without_voids(self):
names_without_voids = [name for name in self._names if self._flds[name] is not Void]
@@ -419,7 +419,7 @@
self.ARGS = tuple(args)
assert isinstance(result, LowLevelType)
if isinstance(result, ContainerType):
- raise TypeError, "function result can only be primitive or pointer"
+ raise TypeError("function result can only be primitive or pointer")
self.RESULT = result
def __str__(self):
@@ -475,7 +475,7 @@
return "%s (gcopaque)" % self.tag
def _inline_is_varsize(self, last):
- raise TypeError, "%r cannot be inlined in structure" % self
+ raise TypeError("%r cannot be inlined in structure" % self)
class PyObjectType(ContainerType):
_gckind = 'cpy'
@@ -588,7 +588,7 @@
def __init__(self, TO):
if not isinstance(TO, ContainerType):
- raise TypeError, ("can only point to a Container type, "
+ raise TypeError("can only point to a Container type, "
"not to %s" % (TO,))
self.TO = TO
@@ -697,7 +697,7 @@
def cast_primitive(TGT, value):
ORIG = typeOf(value)
if not isinstance(TGT, Primitive) or not isinstance(ORIG, Primitive):
- raise TypeError, "can only primitive to primitive"
+ raise TypeError("can only primitive to primitive")
if ORIG == TGT:
return value
if ORIG == Char or ORIG == UniChar:
@@ -713,7 +713,7 @@
return TGT._cast(value)
if ORIG == SingleFloat and TGT == Float:
return float(value)
- raise TypeError, "unsupported cast"
+ raise TypeError("unsupported cast")
def _cast_whatever(TGT, value):
from pypy.rpython.lltypesystem import llmemory
@@ -784,13 +784,13 @@
def cast_pointer(PTRTYPE, ptr):
CURTYPE = typeOf(ptr)
if not isinstance(CURTYPE, Ptr) or not isinstance(PTRTYPE, Ptr):
- raise TypeError, "can only cast pointers to other pointers"
+ raise TypeError("can only cast pointers to other pointers")
return ptr._cast_to(PTRTYPE)
def cast_opaque_ptr(PTRTYPE, ptr):
CURTYPE = typeOf(ptr)
if not isinstance(CURTYPE, Ptr) or not isinstance(PTRTYPE, Ptr):
- raise TypeError, "can only cast pointers to other pointers"
+ raise TypeError("can only cast pointers to other pointers")
if CURTYPE == PTRTYPE:
return ptr
if CURTYPE.TO._gckind != PTRTYPE.TO._gckind:
@@ -840,9 +840,9 @@
"""
CURTYPE = typeOf(structptr).TO
if not isinstance(CURTYPE, Struct):
- raise TypeError, "direct_fieldptr: not a struct"
+ raise TypeError("direct_fieldptr: not a struct")
if fieldname not in CURTYPE._flds:
- raise TypeError, "%s has no field %r" % (CURTYPE, fieldname)
+ raise TypeError("%s has no field %r" % (CURTYPE, fieldname))
if not structptr:
raise RuntimeError("direct_fieldptr: NULL argument")
return _subarray._makeptr(structptr._obj, fieldname, structptr._solid)
@@ -855,7 +855,7 @@
"""
CURTYPE = typeOf(arrayptr).TO
if not isinstance(CURTYPE, (Array, FixedSizeArray)):
- raise TypeError, "direct_arrayitems: not an array"
+ raise TypeError("direct_arrayitems: not an array")
if not arrayptr:
raise RuntimeError("direct_arrayitems: NULL argument")
return _subarray._makeptr(arrayptr._obj, 0, arrayptr._solid)
@@ -1088,7 +1088,7 @@
def __call__(self, *args):
if isinstance(self._T, FuncType):
if len(args) != len(self._T.ARGS):
- raise TypeError,"calling %r with wrong argument number: %r" % (self._T, args)
+ raise TypeError("calling %r with wrong argument number: %r" % (self._T, args))
for i, a, ARG in zip(range(len(self._T.ARGS)), args, self._T.ARGS):
if typeOf(a) != ARG:
# ARG could be Void
@@ -1105,11 +1105,11 @@
elif not (isinstance(ARG, ContainerType)
and typeOf(a) == Ptr(ARG)):
args_repr = [typeOf(arg) for arg in args]
- raise TypeError, ("calling %r with wrong argument "
+ raise TypeError("calling %r with wrong argument "
"types: %r" % (self._T, args_repr))
callb = self._obj._callable
if callb is None:
- raise RuntimeError,"calling undefined function"
+ raise RuntimeError("calling undefined function")
return callb(*args)
raise TypeError("%r instance is not a function" % (self._T,))
@@ -1235,7 +1235,7 @@
self._set_offsets(_offsets)
def __nonzero__(self):
- raise RuntimeError, "do not test an interior pointer for nullity"
+ raise RuntimeError("do not test an interior pointer for nullity")
def _get_obj(self):
ob = self._parent
@@ -1462,9 +1462,9 @@
def __init__(self, TYPE, n, initialization=None, parent=None, parentindex=None):
if not isinstance(n, int):
- raise TypeError, "array length must be an int"
+ raise TypeError("array length must be an int")
if n < 0:
- raise ValueError, "negative array length"
+ raise ValueError("negative array length")
_parentable.__init__(self, TYPE)
self.items = [TYPE.OF._allocate(initialization=initialization, parent=self, parentindex=j)
for j in range(n)]
@@ -1754,23 +1754,23 @@
assert n is None
o = _opaque(T, initialization=initialization)
else:
- raise TypeError, "malloc for Structs and Arrays only"
+ raise TypeError("malloc for Structs and Arrays only")
if T._gckind != 'gc' and not immortal and flavor.startswith('gc'):
- raise TypeError, "gc flavor malloc of a non-GC non-immortal structure"
+ raise TypeError("gc flavor malloc of a non-GC non-immortal structure")
solid = immortal or not flavor.startswith('gc') # immortal or non-gc case
return _ptr(Ptr(T), o, solid)
def free(p, flavor):
if flavor.startswith('gc'):
- raise TypeError, "gc flavor free"
+ raise TypeError("gc flavor free")
T = typeOf(p)
if not isinstance(T, Ptr) or p._togckind() != 'raw':
- raise TypeError, "free(): only for pointers to non-gc containers"
+ raise TypeError("free(): only for pointers to non-gc containers")
p._obj0._free()
def functionptr(TYPE, name, **attrs):
if not isinstance(TYPE, FuncType):
- raise TypeError, "functionptr() for FuncTypes only"
+ raise TypeError("functionptr() for FuncTypes only")
try:
hash(tuple(attrs.items()))
except TypeError:
@@ -1783,7 +1783,7 @@
def opaqueptr(TYPE, name, **attrs):
if not isinstance(TYPE, OpaqueType):
- raise TypeError, "opaqueptr() for OpaqueTypes only"
+ raise TypeError("opaqueptr() for OpaqueTypes only")
o = _opaque(TYPE, _name=name, **attrs)
return _ptr(Ptr(TYPE), o, solid=True)
@@ -1802,22 +1802,22 @@
def attachRuntimeTypeInfo(GCSTRUCT, funcptr=None, destrptr=None):
if not isinstance(GCSTRUCT, RttiStruct):
- raise TypeError, "expected a RttiStruct: %s" % GCSTRUCT
+ raise TypeError("expected a RttiStruct: %s" % GCSTRUCT)
GCSTRUCT._attach_runtime_type_info_funcptr(funcptr, destrptr)
return _ptr(Ptr(RuntimeTypeInfo), GCSTRUCT._runtime_type_info)
def getRuntimeTypeInfo(GCSTRUCT):
if not isinstance(GCSTRUCT, RttiStruct):
- raise TypeError, "expected a RttiStruct: %s" % GCSTRUCT
+ raise TypeError("expected a RttiStruct: %s" % GCSTRUCT)
if GCSTRUCT._runtime_type_info is None:
- raise ValueError, ("no attached runtime type info for GcStruct %s" %
+ raise ValueError("no attached runtime type info for GcStruct %s" %
GCSTRUCT._name)
return _ptr(Ptr(RuntimeTypeInfo), GCSTRUCT._runtime_type_info)
def runtime_type_info(p):
T = typeOf(p)
if not isinstance(T, Ptr) or not isinstance(T.TO, RttiStruct):
- raise TypeError, "runtime_type_info on non-RttiStruct pointer: %s" % p
+ raise TypeError("runtime_type_info on non-RttiStruct pointer: %s" % p)
struct = p._obj
top_parent = top_container(struct)
result = getRuntimeTypeInfo(top_parent._TYPE)
@@ -1827,7 +1827,7 @@
T = typeOf(query_funcptr).TO.ARGS[0]
result2 = query_funcptr(cast_pointer(T, p))
if result != result2:
- raise RuntimeError, ("runtime type-info function for %s:\n"
+ raise RuntimeError("runtime type-info function for %s:\n"
" returned: %s,\n"
"should have been: %s" % (p, result2, result))
return result
Modified: pypy/trunk/pypy/rpython/lltypesystem/rclass.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/rclass.py (original)
+++ pypy/trunk/pypy/rpython/lltypesystem/rclass.py Mon Jun 1 02:00:54 2009
@@ -402,7 +402,7 @@
def get_ll_hash_function(self):
if self.classdef is None:
- raise TyperError, 'missing hash support flag in classdef'
+ raise TyperError('missing hash support flag in classdef')
if self.rtyper.needs_hash_support(self.classdef):
try:
return self._ll_hash_function
Modified: pypy/trunk/pypy/rpython/lltypesystem/rstr.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/rstr.py (original)
+++ pypy/trunk/pypy/rpython/lltypesystem/rstr.py Mon Jun 1 02:00:54 2009
@@ -829,7 +829,7 @@
vchunk = hop.gendirectcall(ll_str.ll_int2oct, vitem,
inputconst(Bool, False))
else:
- raise TyperError, "%%%s is not RPython" % (code, )
+ raise TyperError("%%%s is not RPython" % (code, ))
else:
from pypy.rpython.lltypesystem.rstr import string_repr
vchunk = inputconst(string_repr, thing)
Modified: pypy/trunk/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/trunk/pypy/rpython/ootypesystem/ootype.py (original)
+++ pypy/trunk/pypy/rpython/ootypesystem/ootype.py Mon Jun 1 02:00:54 2009
@@ -999,7 +999,7 @@
def _checkargs(self, args, check_callable=True):
if len(args) != len(self._TYPE.ARGS):
- raise TypeError,"calling %r with wrong argument number: %r" % (self._TYPE, args)
+ raise TypeError("calling %r with wrong argument number: %r" % (self._TYPE, args))
checked_args = []
for a, ARG in zip(args, self._TYPE.ARGS):
@@ -1007,13 +1007,13 @@
if ARG is not Void:
a = enforce(ARG, a)
except TypeError:
- raise TypeError,"calling %r with wrong argument types: %r" % (self._TYPE, args)
+ raise TypeError("calling %r with wrong argument types: %r" % (self._TYPE, args))
checked_args.append(a)
if not check_callable:
return checked_args
callb = self._callable
if callb is None:
- raise RuntimeError,"calling undefined or null function"
+ raise RuntimeError("calling undefined or null function")
return callb, checked_args
def __eq__(self, other):
@@ -1112,7 +1112,7 @@
for meth in self.overloadings:
ARGS = meth._TYPE.ARGS
if ARGS in signatures:
- raise TypeError, 'Bad overloading'
+ raise TypeError('Bad overloading')
signatures.add(ARGS)
def annotate(self, args_s):
@@ -1136,9 +1136,9 @@
if len(matches) == 1:
return matches[0]
elif len(matches) > 1:
- raise TypeError, 'More than one method match, please use explicit casts'
+ raise TypeError('More than one method match, please use explicit casts')
else:
- raise TypeError, 'No suitable overloading found for method'
+ raise TypeError('No suitable overloading found for method')
def _check_signature(self, ARGS1, ARGS2):
if len(ARGS1) != len(ARGS2):
@@ -1540,7 +1540,7 @@
def _check_stamp(self):
if self._stamp != self._dict._stamp:
- raise RuntimeError, 'Dictionary changed during iteration'
+ raise RuntimeError('Dictionary changed during iteration')
def ll_go_next(self):
# NOT_RPYTHON
Modified: pypy/trunk/pypy/rpython/ootypesystem/rstr.py
==============================================================================
--- pypy/trunk/pypy/rpython/ootypesystem/rstr.py (original)
+++ pypy/trunk/pypy/rpython/ootypesystem/rstr.py Mon Jun 1 02:00:54 2009
@@ -319,7 +319,7 @@
assert isinstance(r_arg, IntegerRepr)
vchunk = hop.genop('oostring', [vitem, c8], resulttype=ootype.String)
else:
- raise TyperError, "%%%s is not RPython" % (code, )
+ raise TyperError("%%%s is not RPython" % (code, ))
else:
vchunk = hop.inputconst(string_repr, thing)
#i = inputconst(Signed, i)
Modified: pypy/trunk/pypy/rpython/rlist.py
==============================================================================
--- pypy/trunk/pypy/rpython/rlist.py (original)
+++ pypy/trunk/pypy/rpython/rlist.py Mon Jun 1 02:00:54 2009
@@ -347,7 +347,7 @@
# XXX the special case for pyobj_repr needs to be implemented here as well
# will probably happen during NFS
if r_list == robject.pyobj_repr:
- raise Exception, 'please implement this!'
+ raise Exception('please implement this!')
v_count, v_item = hop.inputargs(Signed, r_list.item_repr)
cLIST = hop.inputconst(Void, r_list.LIST)
return hop.gendirectcall(ll_alloc_and_set, cLIST, v_count, v_item)
Modified: pypy/trunk/pypy/rpython/rmodel.py
==============================================================================
--- pypy/trunk/pypy/rpython/rmodel.py (original)
+++ pypy/trunk/pypy/rpython/rmodel.py Mon Jun 1 02:00:54 2009
@@ -137,12 +137,12 @@
values of this Repr.
This can return None to mean that simply using '==' is fine.
"""
- raise TyperError, 'no equality function for %r' % self
+ raise TyperError('no equality function for %r' % self)
def get_ll_hash_function(self):
"""Return a hash(x) function for low-level values of this Repr.
"""
- raise TyperError, 'no hashing function for %r' % self
+ raise TyperError('no hashing function for %r' % self)
def get_ll_fasthash_function(self):
"""Return a 'fast' hash(x) function for low-level values of this
@@ -178,10 +178,10 @@
return None
def rtype_bltn_list(self, hop):
- raise TyperError, 'no list() support for %r' % self
+ raise TyperError('no list() support for %r' % self)
def rtype_unichr(self, hop):
- raise TyperError, 'no unichr() support for %r' % self
+ raise TyperError('no unichr() support for %r' % self)
# default implementation of some operations
Modified: pypy/trunk/pypy/rpython/rstr.py
==============================================================================
--- pypy/trunk/pypy/rpython/rstr.py (original)
+++ pypy/trunk/pypy/rpython/rstr.py Mon Jun 1 02:00:54 2009
@@ -227,7 +227,7 @@
def rtype_method_replace(self, hop):
rstr = hop.args_r[0].repr
if not (hop.args_r[1] == rstr.char_repr and hop.args_r[2] == rstr.char_repr):
- raise TyperError, 'replace only works for char args'
+ raise TyperError('replace only works for char args')
v_str, v_c1, v_c2 = hop.inputargs(rstr.repr, rstr.char_repr, rstr.char_repr)
hop.exception_cannot_occur()
return hop.gendirectcall(self.ll.ll_replace_chr_chr, v_str, v_c1, v_c2)
@@ -241,7 +241,7 @@
hop.exception_is_here()
return hop.gendirectcall(self.ll.ll_int, v_str, c_base)
if not hop.args_r[1] == rint.signed_repr:
- raise TyperError, 'base needs to be an int'
+ raise TyperError('base needs to be an int')
v_str, v_base= hop.inputargs(string_repr, rint.signed_repr)
hop.exception_is_here()
return hop.gendirectcall(self.ll.ll_int, v_str, v_base)
Modified: pypy/trunk/pypy/tool/_enum_exceptions_broken.py
==============================================================================
--- pypy/trunk/pypy/tool/_enum_exceptions_broken.py (original)
+++ pypy/trunk/pypy/tool/_enum_exceptions_broken.py Mon Jun 1 02:00:54 2009
@@ -91,18 +91,18 @@
try:
sample = exc(*args)
except:
- raise ValueError, "cannot create instance"
+ raise ValueError("cannot create instance")
if "args" not in sample.__dict__:
- raise ValueError, "args attribute not found in __dict__"
+ raise ValueError("args attribute not found in __dict__")
if args != sample.args:
- raise ValueError, "instance has modified args"
+ raise ValueError("instance has modified args")
for i in range(5):
try: x = sample[i]
except IndexError: x = 42
try: y = args[i]
except IndexError: y = 42
if x != y:
- raise ValueError, "args does not behave like a sequence"
+ raise ValueError("args does not behave like a sequence")
del sample.args
try: x = sample[0]
except: x = 42
@@ -129,7 +129,7 @@
if idx not in self.probed:
self.probed.append(idx)
if self.maxprobe is not None and idx > self.maxprobe:
- raise IndexError, "cheat cheat %d" % idx
+ raise IndexError("cheat cheat %d" % idx)
return "arg%d_%s" % (self.argpos, idx)
def __repr__(self):
if self.probed:
@@ -193,7 +193,7 @@
except Exception, e:
continue
else:
- raise TypeError, "cannot analyse arguments of %s" % exc.__name__
+ raise TypeError("cannot analyse arguments of %s" % exc.__name__)
# for the variable part, don't try combinations
for i in range(minargs, maxargs):
for arg in genArgsToTry(i):
@@ -206,7 +206,7 @@
except:
continue
else:
- raise TypeError, "cannot analyse arguments of %s" % exc.__name__
+ raise TypeError("cannot analyse arguments of %s" % exc.__name__)
return minargs, maxargs, res
def captureAssignments(exc, args):
Modified: pypy/trunk/pypy/tool/algo/unionfind.py
==============================================================================
--- pypy/trunk/pypy/tool/algo/unionfind.py (original)
+++ pypy/trunk/pypy/tool/algo/unionfind.py Mon Jun 1 02:00:54 2009
@@ -13,7 +13,7 @@
# mapping-like [] access
def __getitem__(self, obj):
if obj not in self.link_to_parent:
- raise KeyError, obj
+ raise KeyError(obj)
ignore, rep, info = self.find(obj)
Modified: pypy/trunk/pypy/tool/cache.py
==============================================================================
--- pypy/trunk/pypy/tool/cache.py (original)
+++ pypy/trunk/pypy/tool/cache.py Mon Jun 1 02:00:54 2009
@@ -44,8 +44,8 @@
return self.content[key]
except KeyError:
if key in self._building:
- raise Exception, "%s recursive building of %r" % (
- self, key)
+ raise Exception("%s recursive building of %r" % (
+ self, key))
self._building[key] = True
try:
result = self._build(key)
Modified: pypy/trunk/pypy/tool/importfun.py
==============================================================================
--- pypy/trunk/pypy/tool/importfun.py (original)
+++ pypy/trunk/pypy/tool/importfun.py Mon Jun 1 02:00:54 2009
@@ -163,7 +163,7 @@
if name in opcode.opmap:
return opcode.opmap[name]
else:
- raise AttributeError, name
+ raise AttributeError(name)
_op_ = _Op()
Modified: pypy/trunk/pypy/tool/isolate.py
==============================================================================
--- pypy/trunk/pypy/tool/isolate.py (original)
+++ pypy/trunk/pypy/tool/isolate.py Mon Jun 1 02:00:54 2009
@@ -47,7 +47,7 @@
if exc_type_module == 'exceptions':
raise getattr(exceptions, exc_type_name)
else:
- raise IsolateException, "%s.%s" % value
+ raise IsolateException("%s.%s" % value)
def _close(self):
if not self._closed:
Modified: pypy/trunk/pypy/tool/makerelease.py
==============================================================================
--- pypy/trunk/pypy/tool/makerelease.py (original)
+++ pypy/trunk/pypy/tool/makerelease.py Mon Jun 1 02:00:54 2009
@@ -12,7 +12,7 @@
def usage():
print "usage: %s [-tag .<micro>] versionbasename" %(py.std.sys.argv[0])
- raise SystemExit, 1
+ raise SystemExit(1)
def cexec(cmd):
logexec(cmd)
@@ -81,7 +81,7 @@
logexec(cmd)
r = os.system(cmd)
if r:
- raise SystemExit, -1
+ raise SystemExit(-1)
# Remove any .pyc files created in the process
target.chdir()
out = cexec("find . -name '*.pyc' -print0 | xargs -0 -r rm")
@@ -100,7 +100,7 @@
NEWURL = BASEURL.replace('.x', micro)
r = os.system("svn cp %s %s" % (BASEURL, NEWURL))
if r:
- raise SystemExit, -1
+ raise SystemExit(-1)
BASEURL = NEWURL
j = 3
Modified: pypy/trunk/pypy/tool/pydis.py
==============================================================================
--- pypy/trunk/pypy/tool/pydis.py (original)
+++ pypy/trunk/pypy/tool/pydis.py Mon Jun 1 02:00:54 2009
@@ -97,8 +97,8 @@
for bytecode in self.bytecodes:
if bytecode.index == index:
return bytecode
- raise ValueError, "no bytecode found on index %s in code \n%s" % (
- index, pydis(self.code))
+ raise ValueError("no bytecode found on index %s in code \n%s" % (
+ index, pydis(self.code)))
def format(self):
lastlineno = -1
Modified: pypy/trunk/pypy/tool/test/isolate_simple.py
==============================================================================
--- pypy/trunk/pypy/tool/test/isolate_simple.py (original)
+++ pypy/trunk/pypy/tool/test/isolate_simple.py Mon Jun 1 02:00:54 2009
@@ -3,13 +3,13 @@
return a+b
def g():
- raise ValueError, "booh"
+ raise ValueError("booh")
class FancyException(Exception):
pass
def h():
- raise FancyException, "booh"
+ raise FancyException("booh")
def bomb():
raise KeyboardInterrupt
Modified: pypy/trunk/pypy/tool/test/test_pytestsupport.py
==============================================================================
--- pypy/trunk/pypy/tool/test/test_pytestsupport.py (original)
+++ pypy/trunk/pypy/tool/test/test_pytestsupport.py Mon Jun 1 02:00:54 2009
@@ -51,7 +51,7 @@
except AssertionError:
pass
else:
- raise AssertionError, "app level AssertionError mixup!"
+ raise AssertionError("app level AssertionError mixup!")
def app_test_exception_with_message():
try:
Modified: pypy/trunk/pypy/translator/backendopt/all.py
==============================================================================
--- pypy/trunk/pypy/translator/backendopt/all.py (original)
+++ pypy/trunk/pypy/translator/backendopt/all.py Mon Jun 1 02:00:54 2009
@@ -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
Modified: pypy/trunk/pypy/translator/backendopt/malloc.py
==============================================================================
--- pypy/trunk/pypy/translator/backendopt/malloc.py (original)
+++ pypy/trunk/pypy/translator/backendopt/malloc.py Mon Jun 1 02:00:54 2009
@@ -544,7 +544,7 @@
newop = SpaceOperation('same_as', [c], op.result)
self.newops.append(newop)
else:
- raise AssertionError, op.opname
+ raise AssertionError(op.opname)
def insert_keepalives(self, newvars):
@@ -637,7 +637,7 @@
newop = SpaceOperation('same_as', [c], op.result)
self.newops.append(newop)
else:
- raise AssertionError, op.opname
+ raise AssertionError(op.opname)
def insert_keepalives(self, newvars):
pass
Modified: pypy/trunk/pypy/translator/c/funcgen.py
==============================================================================
--- pypy/trunk/pypy/translator/c/funcgen.py (original)
+++ pypy/trunk/pypy/translator/c/funcgen.py Mon Jun 1 02:00:54 2009
@@ -181,7 +181,7 @@
else:
return self.db.get(value)
else:
- raise TypeError, "expr(%r)" % (v,)
+ raise TypeError("expr(%r)" % (v,))
# ____________________________________________________________
Modified: pypy/trunk/pypy/translator/c/node.py
==============================================================================
--- pypy/trunk/pypy/translator/c/node.py (original)
+++ pypy/trunk/pypy/translator/c/node.py Mon Jun 1 02:00:54 2009
@@ -831,7 +831,7 @@
assert fnobj.external == 'CPython'
return [CExternalFunctionCodeGenerator(fnobj, db)]
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'
Modified: pypy/trunk/pypy/translator/c/test/test_extfunc.py
==============================================================================
--- pypy/trunk/pypy/translator/c/test/test_extfunc.py (original)
+++ pypy/trunk/pypy/translator/c/test/test_extfunc.py Mon Jun 1 02:00:54 2009
@@ -610,7 +610,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):
Modified: pypy/trunk/pypy/translator/cli/carbonpython.py
==============================================================================
--- pypy/trunk/pypy/translator/cli/carbonpython.py (original)
+++ pypy/trunk/pypy/translator/cli/carbonpython.py Mon Jun 1 02:00:54 2009
@@ -52,7 +52,7 @@
self.inputtypes = args
self.namespace = kwds.pop('namespace', None)
if len(kwds) > 0:
- raise TypeError, "unexpected keyword argument: '%s'" % kwds.keys()[0]
+ raise TypeError("unexpected keyword argument: '%s'" % kwds.keys()[0])
def __call__(self, func):
func._inputtypes_ = self.inputtypes
Modified: pypy/trunk/pypy/translator/cli/dotnet.py
==============================================================================
--- pypy/trunk/pypy/translator/cli/dotnet.py (original)
+++ pypy/trunk/pypy/translator/cli/dotnet.py Mon Jun 1 02:00:54 2009
@@ -306,7 +306,7 @@
self._load_class()
return getattr(self._PythonNet_class, attr)
else:
- raise AttributeError, attr
+ raise AttributeError(attr)
def __call__(self, *args):
self._load_class()
@@ -429,7 +429,7 @@
return hop.genop('ooupcast', [v_obj], hop.r_result.lowleveltype)
else:
if TYPE not in BOXABLE_TYPES:
- raise TyperError, "Can't box values of type %s" % v_obj.concretetype
+ raise TyperError("Can't box values of type %s" % v_obj.concretetype)
return hop.genop('clibox', [v_obj], hop.r_result.lowleveltype)
@@ -541,8 +541,8 @@
TYPE = type_s.const._INSTANCE
for i, arg_s in enumerate(args_s):
if TYPE is not arg_s.ootype:
- raise TypeError, 'Wrong type of arg #%d: %s expected, %s found' % \
- (i, TYPE, arg_s.ootype)
+ raise TypeError('Wrong type of arg #%d: %s expected, %s found' % \
+ (i, TYPE, arg_s.ootype))
fullname = '%s.%s[]' % (TYPE._namespace, TYPE._classname)
cliArray = get_cli_class(fullname)
return SomeOOInstance(cliArray._INSTANCE)
Modified: pypy/trunk/pypy/translator/cli/test/runtest.py
==============================================================================
--- pypy/trunk/pypy/translator/cli/test/runtest.py (original)
+++ pypy/trunk/pypy/translator/cli/test/runtest.py Mon Jun 1 02:00:54 2009
@@ -232,7 +232,7 @@
i = int(name[len('item'):])
return self[i]
else:
- raise AttributeError, name
+ raise AttributeError(name)
class OOList(list):
def ll_length(self):
Modified: pypy/trunk/pypy/translator/driver.py
==============================================================================
--- pypy/trunk/pypy/translator/driver.py (original)
+++ pypy/trunk/pypy/translator/driver.py Mon Jun 1 02:00:54 2009
@@ -159,7 +159,7 @@
new_goal = cand
break
else:
- raise Exception, "cannot infer complete goal from: %r" % goal
+ raise Exception("cannot infer complete goal from: %r" % goal)
l.append(new_goal)
return l
@@ -227,9 +227,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')
Modified: pypy/trunk/pypy/translator/geninterplevel.py
==============================================================================
--- pypy/trunk/pypy/translator/geninterplevel.py (original)
+++ pypy/trunk/pypy/translator/geninterplevel.py Mon Jun 1 02:00:54 2009
@@ -185,7 +185,7 @@
# add a dummy _issubtype() to builtins
if not hasattr(__builtin__, '_issubtype'):
def _issubtype(cls1, cls2):
- raise TypeError, "this dummy should *not* be reached"
+ raise TypeError("this dummy should *not* be reached")
__builtin__._issubtype = _issubtype
class bltinstub:
@@ -214,7 +214,7 @@
return self.nameof(v.value,
debug=('Constant in the graph of', self.currentfunc))
else:
- raise TypeError, "expr(%r)" % (v,)
+ raise TypeError("expr(%r)" % (v,))
def arglist(self, args, localscope):
res = [self.expr(arg, localscope) for arg in args]
@@ -397,7 +397,7 @@
if meth:
break
else:
- raise Exception, "nameof(%r)" % (obj,)
+ raise Exception("nameof(%r)" % (obj,))
code = meth.im_func.func_code
if namehint and 'namehint' in code.co_varnames[:code.co_argcount]:
@@ -728,7 +728,7 @@
if func is getattr(module, func.__name__, None):
break
else:
- raise Exception, '%r not found in any built-in module' % (func,)
+ raise Exception('%r not found in any built-in module' % (func,))
#if modname == '__builtin__':
# # be lazy
# return "(space.builtin.get(space.str_w(%s)))" % self.nameof(func.__name__)
@@ -995,7 +995,7 @@
return 'space.sys.get("stdout")'
if fil is sys.stderr:
return 'space.sys.get("stderr")'
- raise Exception, 'Cannot translate an already-open file: %r' % (fil,)
+ raise Exception('Cannot translate an already-open file: %r' % (fil,))
def gen_source(self, fname, ftmpname=None, file=file):
self.fname = fname
@@ -1447,7 +1447,7 @@
f.close()
self._storage[name] = StringIO.StringIO(data)
else:
- raise ValueError, "mode %s not supported" % mode
+ raise ValueError("mode %s not supported" % mode)
self._file = self._storage[name]
def __getattr__(self, name):
return getattr(self._file, name)
@@ -1489,7 +1489,7 @@
if os.path.isdir(libdir):
break
else:
- raise Exception, "cannot find pypy/lib directory"
+ raise Exception("cannot find pypy/lib directory")
sys.path.insert(0, libdir)
try:
if faked_set:
Modified: pypy/trunk/pypy/translator/gensupp.py
==============================================================================
--- pypy/trunk/pypy/translator/gensupp.py (original)
+++ pypy/trunk/pypy/translator/gensupp.py Mon Jun 1 02:00:54 2009
@@ -99,7 +99,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):
Modified: pypy/trunk/pypy/translator/goal/bench-windows.py
==============================================================================
--- pypy/trunk/pypy/translator/goal/bench-windows.py (original)
+++ pypy/trunk/pypy/translator/goal/bench-windows.py Mon Jun 1 02:00:54 2009
@@ -49,7 +49,7 @@
if line.startswith(pattern):
break
else:
- raise ValueError, 'this is no valid output: %r' % txt
+ raise ValueError('this is no valid output: %r' % txt)
return float(line.split()[len(pattern.split())])
def run_cmd(cmd):
Modified: pypy/trunk/pypy/translator/goal/win32/gc_patch_windows.py
==============================================================================
--- pypy/trunk/pypy/translator/goal/win32/gc_patch_windows.py (original)
+++ pypy/trunk/pypy/translator/goal/win32/gc_patch_windows.py Mon Jun 1 02:00:54 2009
@@ -103,7 +103,7 @@
for old, new in REPLACE.items():
newsrc = src.replace(old, new)
if newsrc == src:
- raise ValueError, "this makefile does not contain %s" % old
+ raise ValueError("this makefile does not contain %s" % old)
src = newsrc
return src
@@ -113,7 +113,7 @@
if name.lower() == 'makefile':
return name
else:
- raise ValueError, 'Makefile not found'
+ raise ValueError('Makefile not found')
try:
name = find_file()
Modified: pypy/trunk/pypy/translator/jvm/test/runtest.py
==============================================================================
--- pypy/trunk/pypy/translator/jvm/test/runtest.py (original)
+++ pypy/trunk/pypy/translator/jvm/test/runtest.py Mon Jun 1 02:00:54 2009
@@ -20,7 +20,7 @@
i = int(name[len('item'):])
return self[i]
else:
- raise AttributeError, name
+ raise AttributeError(name)
# CLI duplicate
class OOList(list):
Modified: pypy/trunk/pypy/translator/stackless/test/test_transform.py
==============================================================================
--- pypy/trunk/pypy/translator/stackless/test/test_transform.py (original)
+++ pypy/trunk/pypy/translator/stackless/test/test_transform.py Mon Jun 1 02:00:54 2009
@@ -253,7 +253,7 @@
s_returnvar = annotator.build_types(fn, [s_list_of_strings])
if not isinstance(s_returnvar, annmodel.SomeInteger):
- raise Exception, "this probably isn't going to work"
+ raise Exception("this probably isn't going to work")
t.buildrtyper().specialize()
from pypy.translator.transform import insert_ll_stackcheck
Modified: pypy/trunk/pypy/translator/stackless/transform.py
==============================================================================
--- pypy/trunk/pypy/translator/stackless/transform.py (original)
+++ pypy/trunk/pypy/translator/stackless/transform.py Mon Jun 1 02:00:54 2009
@@ -611,7 +611,7 @@
args = vars_to_save(block)
for a in args:
if a not in parms:
- raise Exception, "not covered needed value at resume_point %r"%(label,)
+ raise Exception("not covered needed value at resume_point %r"%(label,))
if parms[0] is not None: # returns= case
res = parms[0]
args = [arg for arg in args if arg is not res]
Modified: pypy/trunk/pypy/translator/test/snippet.py
==============================================================================
--- pypy/trunk/pypy/translator/test/snippet.py (original)
+++ pypy/trunk/pypy/translator/test/snippet.py Mon Jun 1 02:00:54 2009
@@ -740,7 +740,7 @@
return x
def func_producing_exception():
- raise ValueError, "this might e.g. block the caller"
+ raise ValueError("this might e.g. block the caller")
def funccallsex():
return func_producing_exception()
@@ -878,7 +878,7 @@
try:
exception_deduction0(2)
if x:
- raise Exc, Exc()
+ raise Exc(Exc())
except Exc, e:
witness(e)
return e
Modified: pypy/trunk/pypy/translator/tool/taskengine.py
==============================================================================
--- pypy/trunk/pypy/translator/tool/taskengine.py (original)
+++ pypy/trunk/pypy/translator/tool/taskengine.py Mon Jun 1 02:00:54 2009
@@ -71,7 +71,7 @@
else:
break
else:
- raise RuntimeError, "circular dependecy"
+ raise RuntimeError("circular dependecy")
plan.append(cand)
for constr in constraints:
Modified: pypy/trunk/pypy/translator/translator.py
==============================================================================
--- pypy/trunk/pypy/translator/translator.py (original)
+++ pypy/trunk/pypy/translator/translator.py Mon Jun 1 02:00:54 2009
@@ -141,7 +141,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):
More information about the Pypy-commit
mailing list