From benjamin at codespeak.net Mon Jun 1 00:45:17 2009 From: benjamin at codespeak.net (benjamin at codespeak.net) Date: Mon, 1 Jun 2009 00:45:17 +0200 (CEST) Subject: [pypy-svn] r65520 - pypy/trunk/pypy/rlib Message-ID: <20090531224517.ED754169F95@codespeak.net> Author: benjamin Date: Mon Jun 1 00:45:16 2009 New Revision: 65520 Modified: pypy/trunk/pypy/rlib/rmd5.py Log: fix encoding Modified: pypy/trunk/pypy/rlib/rmd5.py ============================================================================== --- pypy/trunk/pypy/rlib/rmd5.py (original) +++ pypy/trunk/pypy/rlib/rmd5.py Mon Jun 1 00:45:16 2009 @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- coding: iso-8859-1 -*- """ RPython implementation of MD5 checksums. From benjamin at codespeak.net Mon Jun 1 01:33:53 2009 From: benjamin at codespeak.net (benjamin at codespeak.net) Date: Mon, 1 Jun 2009 01:33:53 +0200 (CEST) Subject: [pypy-svn] r65521 - pypy/trunk/pypy/translator/microbench/pybench Message-ID: <20090531233353.4C345169EB8@codespeak.net> Author: benjamin Date: Mon Jun 1 01:33:51 2009 New Revision: 65521 Modified: pypy/trunk/pypy/translator/microbench/pybench/CommandLine.py pypy/trunk/pypy/translator/microbench/pybench/Exceptions.py pypy/trunk/pypy/translator/microbench/pybench/Strings.py pypy/trunk/pypy/translator/microbench/pybench/platform.py Log: fix some encoding issues in pybench Modified: pypy/trunk/pypy/translator/microbench/pybench/CommandLine.py ============================================================================== --- pypy/trunk/pypy/translator/microbench/pybench/CommandLine.py (original) +++ pypy/trunk/pypy/translator/microbench/pybench/CommandLine.py Mon Jun 1 01:33:51 2009 @@ -6,8 +6,8 @@ TODO: - ? Incorporate the changes made by (see Inbox) - ? Add number range option using srange() + - Incorporate the changes made by (see Inbox) + - Add number range option using srange() Copyright (c) 1997-2001, Marc-Andre Lemburg; mailto:mal at lemburg.com Copyright (c) 2000-2001, eGenix.com Software GmbH; mailto:info at egenix.com @@ -114,7 +114,7 @@ def __init__(self,name,help=None): if not name[:1] == '-': - raise TypeError,'option names must start with "-"' + raise TypeError('option names must start with "-"') if name[1:2] == '-': self.prefix = '--' self.name = name[2:] @@ -280,12 +280,12 @@ # Process startup rc = self.startup() if rc is not None: - raise SystemExit,rc + raise SystemExit(rc) # Parse command line rc = self.parse() if rc is not None: - raise SystemExit,rc + raise SystemExit(rc) # Start application rc = self.main() @@ -308,7 +308,7 @@ traceback.print_exc(20) rc = 1 - raise SystemExit,rc + raise SystemExit(rc) def add_option(self, option): @@ -339,7 +339,7 @@ program. It defaults to 0 which usually means: OK. """ - raise SystemExit, rc + raise SystemExit(rc) def parse(self): @@ -409,7 +409,7 @@ else: rc = handler(value) if rc is not None: - raise SystemExit, rc + raise SystemExit(rc) # Apply final file check (for backward compatibility) rc = self.check_files(self.files) Modified: pypy/trunk/pypy/translator/microbench/pybench/Exceptions.py ============================================================================== --- pypy/trunk/pypy/translator/microbench/pybench/Exceptions.py (original) +++ pypy/trunk/pypy/translator/microbench/pybench/Exceptions.py Mon Jun 1 01:33:51 2009 @@ -20,15 +20,15 @@ except: pass try: - raise error,"something" + raise error("something") except: pass try: - raise error,"something" + raise error("something") except: pass try: - raise error,"something" + raise error("something") except: pass Modified: pypy/trunk/pypy/translator/microbench/pybench/Strings.py ============================================================================== --- pypy/trunk/pypy/translator/microbench/pybench/Strings.py (original) +++ pypy/trunk/pypy/translator/microbench/pybench/Strings.py Mon Jun 1 01:33:51 2009 @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from pybench import Test from string import join @@ -466,7 +467,7 @@ def test(self): - data = ('abc', '123', ' ', '???', '?'*10) + data = ('abc', '123', ' ', '??????', '??'*10) len_data = len(data) for i in xrange(self.rounds): @@ -555,7 +556,7 @@ def calibrate(self): data = ('abc', '123', ' ', '\u1234\u2345\u3456', '\uFFFF'*10) - data = ('abc', '123', ' ', '???', '?'*10) + data = ('abc', '123', ' ', '??????', '??'*10) len_data = len(data) for i in xrange(self.rounds): Modified: pypy/trunk/pypy/translator/microbench/pybench/platform.py ============================================================================== --- pypy/trunk/pypy/translator/microbench/pybench/platform.py (original) +++ pypy/trunk/pypy/translator/microbench/pybench/platform.py Mon Jun 1 01:33:51 2009 @@ -11,10 +11,10 @@ version 1.0 as the final version. Still needed: - ? more support for WinCE - ? support for MS-DOS (PythonDX ?) - ? support for Amiga and other still unsupported platforms running Python - ? support for additional Linux distributions + - more support for WinCE + - support for MS-DOS (PythonDX ?) + - support for Amiga and other still unsupported platforms running Python + - support for additional Linux distributions Many thanks to all those who helped adding platform specific checks (in no particular order): @@ -276,7 +276,7 @@ def __init__(self,cmd,mode='r',bufsize=None): if mode != 'r': - raise ValueError,'popen()-emulation only supports read mode' + raise ValueError('popen()-emulation only supports read mode') import tempfile self.tmpfile = tmpfile = tempfile.mktemp() os.system(cmd + ' > %s' % tmpfile) @@ -387,7 +387,7 @@ pipe = popen(cmd) info = pipe.read() if pipe.close(): - raise os.error,'command failed' + raise os.error('command failed') # XXX How can I supress shell errors from being written # to stderr ? except os.error,why: From benjamin at codespeak.net Mon Jun 1 02:01:09 2009 From: benjamin at codespeak.net (benjamin at codespeak.net) Date: Mon, 1 Jun 2009 02:01:09 +0200 (CEST) Subject: [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 Message-ID: <20090601000109.A18C4169F0A@codespeak.net> 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 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 .] 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): From santagada at codespeak.net Mon Jun 1 03:08:41 2009 From: santagada at codespeak.net (santagada at codespeak.net) Date: Mon, 1 Jun 2009 03:08:41 +0200 (CEST) Subject: [pypy-svn] r65523 - in pypy/branch/js-refactoring/pypy/lang/js: . test test/ecma Message-ID: <20090601010841.B2F62169F1D@codespeak.net> Author: santagada Date: Mon Jun 1 03:08:39 2009 New Revision: 65523 Removed: pypy/branch/js-refactoring/pypy/lang/js/conftest.py Modified: pypy/branch/js-refactoring/pypy/lang/js/astbuilder.py pypy/branch/js-refactoring/pypy/lang/js/interpreter.py pypy/branch/js-refactoring/pypy/lang/js/js_interactive.py pypy/branch/js-refactoring/pypy/lang/js/jscode.py pypy/branch/js-refactoring/pypy/lang/js/jsobj.py pypy/branch/js-refactoring/pypy/lang/js/operations.py pypy/branch/js-refactoring/pypy/lang/js/test/ecma/conftest.py pypy/branch/js-refactoring/pypy/lang/js/test/test_interp.py Log: Applied hpk patches to conftest, unskipped test_interpreter tests and fixed pypy_repr, fixed propertyvalue pairs, fixed with statement, improved js_interactive error messages. Modified: pypy/branch/js-refactoring/pypy/lang/js/astbuilder.py ============================================================================== --- pypy/branch/js-refactoring/pypy/lang/js/astbuilder.py (original) +++ pypy/branch/js-refactoring/pypy/lang/js/astbuilder.py Mon Jun 1 03:08:39 2009 @@ -223,7 +223,12 @@ def visit_propertynameandvalue(self, node): pos = self.get_pos(node) - left = self.dispatch(node.children[0]) + l = node.children[0] + if l.symbol == "IDENTIFIERNAME": + lpos = self.get_pos(l) + left = operations.Identifier(lpos, l.additional_info) + else: + left = self.dispatch(l) right = self.dispatch(node.children[1]) return operations.PropertyInit(pos,left,right) Modified: pypy/branch/js-refactoring/pypy/lang/js/interpreter.py ============================================================================== --- pypy/branch/js-refactoring/pypy/lang/js/interpreter.py (original) +++ pypy/branch/js-refactoring/pypy/lang/js/interpreter.py Mon Jun 1 03:08:39 2009 @@ -627,8 +627,8 @@ def Construct(self, ctx, args=[]): return create_object(ctx, 'Date', Value = W_FloatNumber(0.0)) -def pypy_repr(ctx, repr, w_arg): - return W_String(w_arg.__class__.__name__) +def pypy_repr(ctx, args, this): + return W_String(args[0].__class__.__name__) def put_values(ctx, obj, dictvalues): for key,value in dictvalues.iteritems(): @@ -829,8 +829,8 @@ w_Global.Put(ctx, 'this', w_Global) - # DEBUGGING - if 0: + # debugging + if not we_are_translated(): w_Global.Put(ctx, 'pypy_repr', W_Builtin(pypy_repr)) self.global_context = ctx Modified: pypy/branch/js-refactoring/pypy/lang/js/js_interactive.py ============================================================================== --- pypy/branch/js-refactoring/pypy/lang/js/js_interactive.py (original) +++ pypy/branch/js-refactoring/pypy/lang/js/js_interactive.py Mon Jun 1 03:08:39 2009 @@ -11,6 +11,7 @@ from pypy.lang.js.jsparser import parse, ParseError from pypy.lang.js.jsobj import W_Builtin, W_String, ThrowException, w_Undefined from pypy.rlib.streamio import open_file_as_stream +from pypy.lang.js.jscode import JsCode import code sys.ps1 = 'js> ' @@ -31,6 +32,11 @@ except ImportError: pass +DEBUG = False + +def debugjs(ctx, args, this): + global DEBUG + DEBUG = True def loadjs(ctx, args, this): filename = args[0].ToString() @@ -53,7 +59,7 @@ self.interpreter.w_Global.Put(ctx, 'quit', W_Builtin(quitjs)) self.interpreter.w_Global.Put(ctx, 'load', W_Builtin(loadjs)) self.interpreter.w_Global.Put(ctx, 'trace', W_Builtin(tracejs)) - + self.interpreter.w_Global.Put(ctx, 'debug', W_Builtin(debugjs)) def runcodefromfile(self, filename): f = open_file_as_stream(filename) @@ -67,6 +73,10 @@ traceback. """ try: + if DEBUG: + bytecode = JsCode() + ast.emit(bytecode) + print bytecode res = self.interpreter.run(ast, interactive=True) if res not in (None, w_Undefined): try: @@ -113,7 +123,7 @@ print ' '*4 + \ ' '*exc.source_pos.columnno + \ '^' - print 'Syntax Error' + print 'Syntax Error:', exc.errorinformation.failure_reasons def interact(self, banner=None): if banner is None: Modified: pypy/branch/js-refactoring/pypy/lang/js/jscode.py ============================================================================== --- pypy/branch/js-refactoring/pypy/lang/js/jscode.py (original) +++ pypy/branch/js-refactoring/pypy/lang/js/jscode.py Mon Jun 1 03:08:39 2009 @@ -923,11 +923,9 @@ # ---------------- with support --------------------- class WITH_START(Opcode): - def __init__(self, name): - self.name = name - def eval(self, ctx, stack): - ctx.push_object(ctx.resolve_identifier(ctx, self.name).ToObject(ctx)) + obj = stack.pop().ToObject(ctx) + ctx.push_object(obj) class WITH_END(Opcode): def eval(self, ctx, stack): Modified: pypy/branch/js-refactoring/pypy/lang/js/jsobj.py ============================================================================== --- pypy/branch/js-refactoring/pypy/lang/js/jsobj.py (original) +++ pypy/branch/js-refactoring/pypy/lang/js/jsobj.py Mon Jun 1 03:08:39 2009 @@ -292,7 +292,7 @@ return self.callfuncbi(ctx, args, None) def type(self): - return 'builtin' + return self.Class class W_ListObject(W_PrimitiveObject): def tolist(self): @@ -427,7 +427,14 @@ try: return float(self.strval) except ValueError: - return NAN + try: + return float(int(self.strval, 16)) + except ValueError: + try: + return float(int(self.strval, 8)) + except ValueError: + return NAN + class W_BaseNumber(W_Primitive): """ Base class for numbers, both known to be floats Modified: pypy/branch/js-refactoring/pypy/lang/js/operations.py ============================================================================== --- pypy/branch/js-refactoring/pypy/lang/js/operations.py (original) +++ pypy/branch/js-refactoring/pypy/lang/js/operations.py Mon Jun 1 03:08:39 2009 @@ -721,14 +721,14 @@ bytecode.emit('LOAD_UNDEFINED') class With(Statement): - def __init__(self, pos, identifier, body): + def __init__(self, pos, expr, body): self.pos = pos - assert isinstance(identifier, VariableIdentifier) - self.identifier = identifier.identifier + self.expr = expr self.body = body def emit(self, bytecode): - bytecode.emit('WITH_START', self.identifier) + self.expr.emit(bytecode) + bytecode.emit('WITH_START') self.body.emit(bytecode) bytecode.emit('WITH_END') Modified: pypy/branch/js-refactoring/pypy/lang/js/test/ecma/conftest.py ============================================================================== --- pypy/branch/js-refactoring/pypy/lang/js/test/ecma/conftest.py (original) +++ pypy/branch/js-refactoring/pypy/lang/js/test/ecma/conftest.py Mon Jun 1 03:08:39 2009 @@ -14,32 +14,31 @@ def overriden_evaljs(ctx, args, this): try: - return evaljs(ctx, args, this) + w_eval = W_Eval(ctx) + return w_eval.Call(ctx, args, this) except JsBaseExcept: return W_String("error") -passing_tests = ['Number', 'Boolean'] +passing_tests = ['Number', 'Boolean', 'Array'] -class JSDirectory(py.test.collect.Directory): +class EcmatestPlugin: + def pytest_addoption(self, parser): + parser.addoption('--ecma', + action="store_true", dest="ecma", default=False, + help="run js interpreter ecma tests" + ) - def filefilter(self, path): - if not py.test.config.option.ecma: - for i in passing_tests: - if i in str(path): - break - else: - return False - if path.check(file=1): - return (path.basename not in exclusionlist) and (path.ext == '.js') - - def join(self, name): - if not name.endswith('.js'): - return super(Directory, self).join(name) - p = self.fspath.join(name) - if p.check(file=1): - return JSTestFile(p, parent=self) + def pytest_collect_file(self, path, parent): + if parent.name not in passing_tests: + return + if path.ext == ".js" and path.basename not in exclusionlist: + if not parent.config.option.ecma: + py.test.skip("ECMA tests disabled, run with --ecma") + return JSTestFile(path, parent=parent) + +ConftestPlugin = EcmatestPlugin -class JSTestFile(py.test.collect.Module): +class JSTestFile(py.test.collect.File): def init_interp(cls): if hasattr(cls, 'interp'): cls.testcases.PutValue(W_Array(), cls.interp.global_context) @@ -62,13 +61,7 @@ self.name = fspath.purebasename self.fspath = fspath - def run(self): - if not py.test.config.option.ecma: - for i in passing_tests: - if i in self.listnames(): - break - else: - py.test.skip("ECMA tests disabled, run with --ecma") + def collect(self): if py.test.config.option.collectonly: return self.init_interp() @@ -81,23 +74,20 @@ except JsBaseExcept: raise Failed(msg="Javascript Error", excinfo=py.code.ExceptionInfo()) except: - raise Failed(excinfo=py.code.ExceptionInfo()) + raise ctx = self.interp.global_context testcases = ctx.resolve_identifier(ctx, 'testcases') self.tc = ctx.resolve_identifier(ctx, 'tc') testcount = testcases.Get(ctx, 'length').ToInt32(ctx) self.testcases = testcases - return range(testcount) - - def join(self, number): - return JSTestItem(number, parent = self) + return [JSTestItem(number, parent=self) for number in range(testcount)] class JSTestItem(py.test.collect.Item): def __init__(self, number, parent=None): super(JSTestItem, self).__init__(str(number), parent) self.number = number - def run(self): + def runtest(self): ctx = JSTestFile.interp.global_context r3 = ctx.resolve_identifier(ctx, 'run_test') w_test_number = W_IntNumber(self.number) @@ -110,4 +100,3 @@ def _getpathlineno(self): return self.parent.parent.fspath, 0 -Directory = JSDirectory Modified: pypy/branch/js-refactoring/pypy/lang/js/test/test_interp.py ============================================================================== --- pypy/branch/js-refactoring/pypy/lang/js/test/test_interp.py (original) +++ pypy/branch/js-refactoring/pypy/lang/js/test/test_interp.py Mon Jun 1 03:08:39 2009 @@ -519,6 +519,14 @@ print(x); """, ['4', '2', '3', '4']) +def test_with_expr(): + assertp(""" + var x = 4; + with({x:2}) { + print(x); + } + """, ['2']) + def test_bitops(): yield assertv, "2 ^ 2;", 0 yield assertv, "2 & 3;", 2 @@ -563,7 +571,6 @@ yield assertv, "x=2; x^=2; x;", 0 def test_not(): - py.test.skip("not supported") assertv("~1", -2) def test_delete_member(): @@ -625,9 +632,11 @@ assertv("var x = new Boolean; x.toString();", 'false') def test_pypy_repr(): - py.test.skip("I don't understand, but it does not work") - assertv("pypy_repr(3);", 'W_IntNumber') - assertv("pypy_repr(3.0);", 'W_FloatNumber') + yield assertv, "pypy_repr(3);", 'W_IntNumber' + # See optimization on astbuilder.py for a reason to the test below + yield assertv, "pypy_repr(3.0);", 'W_IntNumber' + yield assertv, "pypy_repr(3.5);", 'W_FloatNumber' + yield assertv, "x=9999; pypy_repr(x*x*x);", 'W_FloatNumber' def test_number(): assertp("print(Number(void 0))", "NaN") From santagada at codespeak.net Mon Jun 1 04:27:23 2009 From: santagada at codespeak.net (santagada at codespeak.net) Date: Mon, 1 Jun 2009 04:27:23 +0200 (CEST) Subject: [pypy-svn] r65524 - pypy/branch/js-refactoring/pypy/lang/js Message-ID: <20090601022723.CB9A8169F0A@codespeak.net> Author: santagada Date: Mon Jun 1 04:27:20 2009 New Revision: 65524 Modified: pypy/branch/js-refactoring/pypy/lang/js/js_interactive.py Log: better debug info on interpreter Modified: pypy/branch/js-refactoring/pypy/lang/js/js_interactive.py ============================================================================== --- pypy/branch/js-refactoring/pypy/lang/js/js_interactive.py (original) +++ pypy/branch/js-refactoring/pypy/lang/js/js_interactive.py Mon Jun 1 04:27:20 2009 @@ -9,9 +9,9 @@ import getopt from pypy.lang.js.interpreter import load_source, Interpreter, load_file from pypy.lang.js.jsparser import parse, ParseError -from pypy.lang.js.jsobj import W_Builtin, W_String, ThrowException, w_Undefined +from pypy.lang.js.jsobj import W_Builtin, W_String, ThrowException, \ + w_Undefined, W_Boolean from pypy.rlib.streamio import open_file_as_stream -from pypy.lang.js.jscode import JsCode import code sys.ps1 = 'js> ' @@ -36,7 +36,8 @@ def debugjs(ctx, args, this): global DEBUG - DEBUG = True + DEBUG = not DEBUG + return W_Boolean(DEBUG) def loadjs(ctx, args, this): filename = args[0].ToString() @@ -47,6 +48,7 @@ arguments = args import pdb pdb.set_trace() + return w_Undefined def quitjs(ctx, args, this): sys.exit(0) @@ -73,13 +75,13 @@ traceback. """ try: - if DEBUG: - bytecode = JsCode() - ast.emit(bytecode) - print bytecode res = self.interpreter.run(ast, interactive=True) + if DEBUG: + print self.interpreter._code if res not in (None, w_Undefined): try: + if DEBUG: + print repr(res) print res.ToString(self.interpreter.w_Global) except ThrowException, exc: print exc.exception.ToString(self.interpreter.w_Global) From pedronis at codespeak.net Mon Jun 1 08:22:28 2009 From: pedronis at codespeak.net (pedronis at codespeak.net) Date: Mon, 1 Jun 2009 08:22:28 +0200 (CEST) Subject: [pypy-svn] r65525 - 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 Message-ID: <20090601062228.61467169F05@codespeak.net> Author: pedronis Date: Mon Jun 1 08:22:12 2009 New Revision: 65525 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: reverting 65522, it broke a couple tests in applevel and lib-python tests not completely clear why, in general our error code is not that well tested by our own tests Modified: pypy/trunk/pypy/annotation/annrpython.py ============================================================================== --- pypy/trunk/pypy/annotation/annrpython.py (original) +++ pypy/trunk/pypy/annotation/annrpython.py Mon Jun 1 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 2009 @@ -37,8 +37,9 @@ 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 @@ -74,7 +75,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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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,8 +217,9 @@ + 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): @@ -244,13 +245,15 @@ 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 2009 @@ -12,7 +12,7 @@ def usage(): print "usage: %s [-tag .] 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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 08:22:12 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): From antocuni at codespeak.net Mon Jun 1 12:09:14 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 1 Jun 2009 12:09:14 +0200 (CEST) Subject: [pypy-svn] r65526 - pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli Message-ID: <20090601100914.966CE169F1C@codespeak.net> Author: antocuni Date: Mon Jun 1 12:09:12 2009 New Revision: 65526 Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/method.py Log: ignore guard_nonvirtualized, for now Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/method.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/method.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/method.py Mon Jun 1 12:09:12 2009 @@ -542,7 +542,7 @@ self.store_result(op) def emit_op_guard_nonvirtualized(self, op): - raise NotImplementedError + pass def lltype_only(self, op): print 'Operation %s is lltype specific, should not get here!' % op.getopname() From arigo at codespeak.net Mon Jun 1 17:56:48 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 1 Jun 2009 17:56:48 +0200 (CEST) Subject: [pypy-svn] r65527 - in pypy/branch/pyjitpl5-experiments/pypy/rpython/memory: gc gctransform Message-ID: <20090601155648.183A0169F1E@codespeak.net> Author: arigo Date: Mon Jun 1 17:56:46 2009 New Revision: 65527 Modified: pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gc/generation.py pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gctransform/framework.py Log: Turn 'remember_young_pointer' into a function attached to 'self' instead of a regular method. For the reasoning see the comment. Modified: pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gc/generation.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gc/generation.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gc/generation.py Mon Jun 1 17:56:46 2009 @@ -61,6 +61,7 @@ # GCFLAG_NO_YOUNG_PTRS bit is not set. self.young_objects_with_weakrefs = self.AddressStack() self.reset_nursery() + self._setup_wb() # compute the constant lower bounds for the attributes # largest_young_fixedsize and largest_young_var_basesize. @@ -408,23 +409,30 @@ self.objects_with_weakrefs.append(obj) # for the JIT: a minimal description of the write_barrier() method + # (the JIT assumes it is of the shape + # "if newvalue.int0 & JIT_WB_IF_FLAG: remember_young_pointer()") JIT_WB_IF_FLAG = GCFLAG_NO_YOUNG_PTRS - JIT_WB_THEN_CALL = 'remember_young_pointer' def write_barrier(self, newvalue, addr_struct): if self.header(addr_struct).tid & GCFLAG_NO_YOUNG_PTRS: self.remember_young_pointer(addr_struct, newvalue) - def remember_young_pointer(self, addr_struct, addr): - ll_assert(not self.is_in_nursery(addr_struct), - "nursery object with GCFLAG_NO_YOUNG_PTRS") - if self.is_in_nursery(addr): - self.old_objects_pointing_to_young.append(addr_struct) - self.header(addr_struct).tid &= ~GCFLAG_NO_YOUNG_PTRS - elif addr == NULL: - return - self.write_into_last_generation_obj(addr_struct, addr) - remember_young_pointer._dont_inline_ = True + def _setup_wb(self): + # The purpose of attaching remember_young_pointer to the instance + # instead of keeping it as a regular method is to help the JIT call it. + # Additionally, it makes the code in write_barrier() marginally smaller + # (which is important because it is inlined *everywhere*). + def remember_young_pointer(addr_struct, addr): + ll_assert(not self.is_in_nursery(addr_struct), + "nursery object with GCFLAG_NO_YOUNG_PTRS") + if self.is_in_nursery(addr): + self.old_objects_pointing_to_young.append(addr_struct) + self.header(addr_struct).tid &= ~GCFLAG_NO_YOUNG_PTRS + elif addr == NULL: + return + self.write_into_last_generation_obj(addr_struct, addr) + remember_young_pointer._dont_inline_ = True + self.remember_young_pointer = remember_young_pointer def write_into_last_generation_obj(self, addr_struct, addr): objhdr = self.header(addr_struct) Modified: pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gctransform/framework.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gctransform/framework.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gctransform/framework.py Mon Jun 1 17:56:46 2009 @@ -19,7 +19,7 @@ from pypy.rpython.memory.gctransform.log import log from pypy.tool.sourcetools import func_with_new_name from pypy.rpython.lltypesystem.lloperation import llop, LL_OPERATIONS -import sys +import sys, types class CollectAnalyzer(graphanalyze.GraphAnalyzer): @@ -340,10 +340,11 @@ annmodel.SomeAddress()], annmodel.s_None, inline=True) - func = getattr(GCClass, GCClass.JIT_WB_THEN_CALL).im_func + func = getattr(gcdata.gc, GCClass.JIT_WB_THEN_CALL) + assert isinstance(func, types.FunctionType) # not a bound method, + # but a real function self.write_barrier_failing_case_ptr = getfn(func, - [s_gc, - annmodel.SomeAddress(), + [annmodel.SomeAddress(), annmodel.SomeAddress()], annmodel.s_None) else: From arigo at codespeak.net Mon Jun 1 18:21:05 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 1 Jun 2009 18:21:05 +0200 (CEST) Subject: [pypy-svn] r65528 - pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gctransform Message-ID: <20090601162105.19665168446@codespeak.net> Author: arigo Date: Mon Jun 1 18:21:03 2009 New Revision: 65528 Modified: pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gctransform/framework.py Log: Oups, fix. Modified: pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gctransform/framework.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gctransform/framework.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gctransform/framework.py Mon Jun 1 18:21:03 2009 @@ -340,7 +340,7 @@ annmodel.SomeAddress()], annmodel.s_None, inline=True) - func = getattr(gcdata.gc, GCClass.JIT_WB_THEN_CALL) + func = gcdata.gc.remember_young_pointer assert isinstance(func, types.FunctionType) # not a bound method, # but a real function self.write_barrier_failing_case_ptr = getfn(func, From arigo at codespeak.net Mon Jun 1 18:30:15 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 1 Jun 2009 18:30:15 +0200 (CEST) Subject: [pypy-svn] r65529 - pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gctransform Message-ID: <20090601163015.E0C08169F4B@codespeak.net> Author: arigo Date: Mon Jun 1 18:30:14 2009 New Revision: 65529 Modified: pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gctransform/framework.py Log: Fix. (I know I should write tests for this directly...) Modified: pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gctransform/framework.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gctransform/framework.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/rpython/memory/gctransform/framework.py Mon Jun 1 18:30:14 2009 @@ -616,11 +616,8 @@ def gct_get_write_barrier_failing_case(self, hop): op = hop.spaceop - c_result = rmodel.inputconst( - lltype.typeOf(self.write_barrier_failing_case_ptr), - self.write_barrier_failing_case_ptr) hop.genop("same_as", - [c_result], + [self.write_barrier_failing_case_ptr], resultvar=op.result) def gct_zero_gc_pointers_inside(self, hop): From arigo at codespeak.net Mon Jun 1 18:31:11 2009 From: arigo at codespeak.net (arigo at codespeak.net) Date: Mon, 1 Jun 2009 18:31:11 +0200 (CEST) Subject: [pypy-svn] r65530 - pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86 Message-ID: <20090601163111.478C7169F4B@codespeak.net> Author: arigo Date: Mon Jun 1 18:31:10 2009 New Revision: 65530 Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/gc.py pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/regalloc.py pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/runner.py Log: In-progress: support for write barriers. "Should work" but there is a bug somewhere still causing a segfault. Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py Mon Jun 1 18:31:10 2009 @@ -42,6 +42,9 @@ def tell(self): return self._mc.tell() + def write(self, data): + self._mc.write(data) + def done(self): self._mc.done() Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/gc.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/gc.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/gc.py Mon Jun 1 18:31:10 2009 @@ -5,15 +5,20 @@ from pypy.translator.tool.cbuild import ExternalCompilationInfo from pypy.jit.backend.x86 import symbolic from pypy.jit.backend.x86.runner import ConstDescr3 -from pypy.jit.backend.x86.ri386 import MODRM +from pypy.jit.backend.x86.ri386 import MODRM, mem, imm32, rel32 +from pypy.jit.backend.x86.ri386 import REG, eax, ecx, edx # ____________________________________________________________ class GcLLDescription: - def __init__(self, gcdescr, mixlevelann): + def __init__(self, gcdescr, cpu): self.gcdescr = gcdescr def _freeze_(self): return True + def do_write_barrier(self, gcref_struct, gcref_newptr): + pass + def gen_write_barrier(self, regalloc, base_reg, value_reg): + pass # ____________________________________________________________ @@ -21,7 +26,7 @@ moving_gc = False gcrootmap = None - def __init__(self, gcdescr, mixlevelann): + def __init__(self, gcdescr, cpu): # grab a pointer to the Boehm 'malloc' function compilation_info = ExternalCompilationInfo(libraries=['gc']) malloc_fn_ptr = rffi.llexternal("GC_malloc", @@ -220,10 +225,11 @@ class GcLLDescr_framework(GcLLDescription): GcRefList = GcRefList - def __init__(self, gcdescr, mixlevelann): + def __init__(self, gcdescr, cpu): from pypy.rpython.memory.gc.base import choose_gc_from_config from pypy.rpython.memory.gctransform import framework - self.translator = mixlevelann.rtyper.annotator.translator + self.cpu = cpu + self.translator = cpu.mixlevelann.rtyper.annotator.translator # to find roots in the assembler, make a GcRootMap name = gcdescr.config.translation.gcrootfinder @@ -243,8 +249,10 @@ 'gcmapstart': lambda: gcrootmap.gcmapstart(), 'gcmapend': lambda: gcrootmap.gcmapend(), } - GCClass, _ = choose_gc_from_config(gcdescr.config) - self.moving_gc = GCClass.moving_gc + self.GCClass, _ = choose_gc_from_config(gcdescr.config) + self.moving_gc = self.GCClass.moving_gc + self.HDRPTR = lltype.Ptr(self.GCClass.HDR) + self.fielddescr_tid = cpu.fielddescrof(self.GCClass.HDR, 'tid') # make a malloc function, with three arguments def malloc_basic(size, type_id, has_finalizer): @@ -254,6 +262,8 @@ self.malloc_basic = malloc_basic self.GC_MALLOC_BASIC = lltype.Ptr(lltype.FuncType( [lltype.Signed, lltype.Signed, lltype.Bool], llmemory.GCREF)) + self.WB_FUNCPTR = lltype.Ptr(lltype.FuncType( + [llmemory.Address, llmemory.Address], lltype.Void)) def sizeof(self, S, translate_support_code): from pypy.rpython.memory.gctypelayout import weakpointer_offset @@ -285,9 +295,52 @@ def get_funcptr_for_new(self): return llhelper(self.GC_MALLOC_BASIC, self.malloc_basic) + def do_write_barrier(self, gcref_struct, gcref_newptr): + hdr_addr = llmemory.cast_ptr_to_adr(gcref_struct) + hdr = llmemory.cast_adr_to_ptr(hdr_addr, self.HDRPTR) + if hdr.tid & self.GCClass.JIT_WB_IF_FLAG: + # get a pointer to the 'remember_young_pointer' function from + # the GC, and call it immediately + funcptr = llop.get_write_barrier_failing_case(self.WB_FUNCPTR) + funcptr(llmemory.cast_ptr_to_adr(gcref_struct), + llmemory.cast_ptr_to_adr(gcref_newptr)) + + def gen_write_barrier(self, assembler, base_reg, value_reg): + assert isinstance(base_reg, REG) + assert isinstance(value_reg, REG) + # XXX very low-level, needs fixing if anything changes :-/ + assembler.mc.TEST(mem(base_reg, 0), imm32(self.GCClass.JIT_WB_IF_FLAG)) + assembler.mc.write('\x74\x0B') # JZ label_end + # xxx longish - save all three registers in REGS; we know that base_reg + # and value_reg are two of these registers, find out the missing one + if base_reg is eax: + if value_reg is ecx: third_reg = edx + elif value_reg is edx: third_reg = ecx + else: assert 0, "bad value_reg" + elif base_reg is ecx: + if value_reg is edx: third_reg = eax + elif value_reg is eax: third_reg = edx + else: assert 0, "bad value_reg" + elif base_reg is edx: + if value_reg is eax: third_reg = ecx + elif value_reg is ecx: third_reg = eax + else: assert 0, "bad value_reg" + else: + assert 0, "bad base_reg" + assembler.mc.PUSH(third_reg) # 1 byte + assembler.mc.PUSH(value_reg) # 1 byte + assembler.mc.PUSH(base_reg) # 1 byte + funcptr = llop.get_write_barrier_failing_case(self.WB_FUNCPTR) + funcaddr = rffi.cast(lltype.Signed, funcptr) + assembler.mc.CALL(rel32(funcaddr)) # 5 bytes + assembler.mc.POP(base_reg) # 1 byte + assembler.mc.POP(value_reg) # 1 byte + assembler.mc.POP(third_reg) # 1 byte + # total: 11 bytes + # ____________________________________________________________ -def get_ll_description(gcdescr, mixlevelann): +def get_ll_description(gcdescr, cpu): if gcdescr is not None: name = gcdescr.config.translation.gctransformer else: @@ -297,4 +350,4 @@ except KeyError: raise NotImplementedError("GC transformer %r not supported by " "the x86 backend" % (name,)) - return cls(gcdescr, mixlevelann) + return cls(gcdescr, cpu) Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/regalloc.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/regalloc.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/regalloc.py Mon Jun 1 18:31:10 2009 @@ -1001,16 +1001,22 @@ def _unpack_fielddescr(self, fielddescr): from pypy.jit.backend.x86.runner import CPU386 - ofs, size, _ = CPU386.unpack_fielddescr(fielddescr) - return imm(ofs), imm(size) + ofs, size, ptr = CPU386.unpack_fielddescr(fielddescr) + return imm(ofs), imm(size), ptr def consider_setfield_gc(self, op, ignored): base_loc = self.make_sure_var_in_reg(op.args[0], op.args) - ofs_loc, size_loc = self._unpack_fielddescr(op.descr) value_loc = self.make_sure_var_in_reg(op.args[1], op.args) + ofs_loc, size_loc, ptr = self._unpack_fielddescr(op.descr) + if ptr: + gc_ll_descr = self.assembler.cpu.gc_ll_descr + gc_ll_descr.gen_write_barrier(self.assembler, base_loc, value_loc) self.eventually_free_vars(op.args) self.PerformDiscard(op, [base_loc, ofs_loc, size_loc, value_loc]) + #def consider_setfield_raw(...): + # like consider_setfield_gc(), except without write barrier support + def consider_strsetitem(self, op, ignored): base_loc = self.make_sure_var_in_reg(op.args[0], op.args) ofs_loc = self.make_sure_var_in_reg(op.args[1], op.args) @@ -1030,7 +1036,7 @@ imm(scale), imm(ofs)]) def consider_getfield_gc(self, op, ignored): - ofs_loc, size_loc = self._unpack_fielddescr(op.descr) + ofs_loc, size_loc, _ = self._unpack_fielddescr(op.descr) base_loc = self.make_sure_var_in_reg(op.args[0], op.args) self.eventually_free_vars(op.args) result_loc = self.force_allocate_reg(op.result, []) Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/runner.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/runner.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/runner.py Mon Jun 1 18:31:10 2009 @@ -103,8 +103,8 @@ self._setup_prebuilt_error('ovf', OverflowError) self._setup_prebuilt_error('zer', ZeroDivisionError) self.generated_mps = r_dict(const_descr_eq, const_descr_hash) - self.gc_ll_descr = get_ll_description(gcdescr, mixlevelann) self._descr_caches = {} + self.gc_ll_descr = get_ll_description(gcdescr, self) self.vtable_offset, _ = symbolic.get_field_token(rclass.OBJECT, 'typeptr', translate_support_code) @@ -504,11 +504,13 @@ v = rffi.cast(rffi.USHORT, vbox.getint()) rffi.cast(rffi.CArrayPtr(rffi.USHORT), gcref)[ofs/2] = v elif size == WORD: - a = rffi.cast(rffi.CArrayPtr(lltype.Signed), gcref) if ptr: ptr = vbox.getptr(llmemory.GCREF) + self.gc_ll_descr.do_write_barrier(gcref, ptr) + a = rffi.cast(rffi.CArrayPtr(lltype.Signed), gcref) a[ofs/WORD] = self.cast_gcref_to_int(ptr) else: + a = rffi.cast(rffi.CArrayPtr(lltype.Signed), gcref) a[ofs/WORD] = vbox.getint() else: raise NotImplementedError("size = %d" % size) From antocuni at codespeak.net Mon Jun 1 19:11:53 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Mon, 1 Jun 2009 19:11:53 +0200 (CEST) Subject: [pypy-svn] r65531 - in pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli: . test Message-ID: <20090601171153.BD1B9169F4B@codespeak.net> Author: antocuni Date: Mon Jun 1 19:11:53 2009 New Revision: 65531 Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/method.py pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/test/test_runner.py Log: add the possibility to change the 'option' and 'tailcall' options at runtime, by setting an environment variable Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/method.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/method.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/method.py Mon Jun 1 19:11:53 2009 @@ -1,4 +1,5 @@ import py +import os from pypy.tool.pairtype import extendabletype from pypy.rlib.objectmodel import compute_unique_id from pypy.rpython.ootypesystem import ootype @@ -132,6 +133,7 @@ debug = False def __init__(self, cpu, name, loop): + self.setoptions() self.cpu = cpu self.name = name self.loop = loop @@ -165,6 +167,29 @@ # ---- self.finish_code() + def _parseopt(self, text): + text = text.lower() + if text[0] == '-': + return text[1:], False + elif text[0] == '+': + return text[1:], True + else: + return text, True + + def setoptions(self): + opts = os.environ.get('PYPYJITOPT') + if opts is None: + pass + parts = opts.split() + for part in parts: + name, value = self._parseopt(part) + if name == 'debug': + self.debug = value + elif name == 'tailcall': + self.tailcall = value + else: + os.write(2, 'Warning: invalid option name: %s\n' % name) + def finish_code(self): delegatetype = dotnet.typeof(LoopDelegate) # initialize the array of genconsts Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/test/test_runner.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/test/test_runner.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/test/test_runner.py Mon Jun 1 19:11:53 2009 @@ -29,3 +29,31 @@ def test_ovf_operations(self, reversed=False): if reversed: py.test.skip('fixme') + + +def test_pypycliopt(): + import os + from pypy.jit.backend.cli.method import Method + + def getmeth(value): + oldenv = os.environ.get('PYPYJITOPT') + os.environ['PYPYJITOPT'] = value + meth = Method.__new__(Method) # evil hack not to call __init__ + meth.setoptions() + if oldenv: + os.environ['PYPYJITOPT'] = oldenv + else: + del os.environ['PYPYJITOPT'] + return meth + + meth = getmeth('') + assert meth.debug == Method.debug + assert meth.tailcall == Method.tailcall + + meth = getmeth('debug -tailcall') + assert meth.debug + assert not meth.tailcall + + meth = getmeth('+debug +tailcall') + assert meth.debug + assert meth.tailcall From fijal at codespeak.net Mon Jun 1 20:35:09 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 1 Jun 2009 20:35:09 +0200 (CEST) Subject: [pypy-svn] r65532 - pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp Message-ID: <20090601183509.642FB169EFB@codespeak.net> Author: fijal Date: Mon Jun 1 20:35:06 2009 New Revision: 65532 Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/history.py pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/resoperation.py Log: Improve printing of resops Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/history.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/history.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/history.py Mon Jun 1 20:35:06 2009 @@ -582,19 +582,22 @@ self.cpu = cpu self.inputargs = None self.operations = [] - def record(self, opnum, argboxes, resbox, descr=None): + def record(self, opnum, argboxes, resbox, descr=None, pc=0, name=""): raise NotImplementedError class History(RunningMatcher): extratext = '' - def record(self, opnum, argboxes, resbox, descr=None): + def record(self, opnum, argboxes, resbox, descr=None, + pc=0, name=""): op = ResOperation(opnum, argboxes, resbox, descr) + op.pc = pc + op.name = name self.operations.append(op) return op class BlackHole(RunningMatcher): extratext = ' (BlackHole)' - def record(self, opnum, argboxes, resbox, descr=None): + def record(self, opnum, argboxes, resbox, descr=None, pc=0, name=""): return None # ____________________________________________________________ Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/resoperation.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/resoperation.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/resoperation.py Mon Jun 1 20:35:06 2009 @@ -15,6 +15,10 @@ # for x86 backend and guards inputargs = None + # debug + name = "" + pc = 0 + def __init__(self, opnum, args, result, descr=None): assert isinstance(opnum, int) self.opnum = opnum @@ -48,11 +52,15 @@ sres = '%s = ' % (self.result,) else: sres = '' + if self.name: + prefix = "%s:%s:" % (self.name, self.pc) + else: + prefix = "" if self.descr is None or we_are_translated(): - return '%s%s(%s)' % (sres, self.getopname(), + return '%s%s%s(%s)' % (prefix, sres, self.getopname(), ', '.join([str(a) for a in self.args])) else: - return '%s%s(%s, descr=%r)' % (sres, self.getopname(), + return '%s%s%s(%s, descr=%r)' % (prefix, sres, self.getopname(), ', '.join([str(a) for a in self.args]), self.descr) def getopname(self): From fijal at codespeak.net Mon Jun 1 20:36:16 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Mon, 1 Jun 2009 20:36:16 +0200 (CEST) Subject: [pypy-svn] r65533 - in pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp: . test Message-ID: <20090601183616.CDC23169F1E@codespeak.net> Author: fijal Date: Mon Jun 1 20:36:15 2009 New Revision: 65533 Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/pyjitpl.py pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_basic.py pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py Log: a test and a fix Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py Mon Jun 1 20:36:15 2009 @@ -156,34 +156,43 @@ assert len(op.suboperations) == 1 op_fail = op.suboperations[0] op.suboperations = [] + self.rebuild_virtuals(op.suboperations, op_fail.args) + op_fail.args = self.new_arguments(op_fail) + op.suboperations.append(op_fail) + op.args = self.new_arguments(op) + return op + + def rebuild_virtuals(self, ops, args): self.already_build_nodes = {} - for arg in op_fail.args: + rebuild = False + for arg in args: node = self.getnode(arg) if node.virtual: - self.rebuild_virtual(op.suboperations, node) - op_fail.args = self.new_arguments(op_fail) + self.rebuild_virtual(ops, node) + if node.virtualized: + rebuild = True # modification in place. Reason for this is explained in mirror # in optimize.py - for node, d in self.additional_stores.iteritems(): - for field, fieldnode in d.iteritems(): - if fieldnode.virtual: - self.rebuild_virtual(op.suboperations, fieldnode) - gop = self._guard_for_node(node) - op.suboperations.append(gop) - op.suboperations.append(ResOperation(rop.SETFIELD_GC, - [node.source, fieldnode.source], None, field)) - for node, d in self.additional_setarrayitems.iteritems(): - for field, (fieldnode, descr) in d.iteritems(): - box = fieldnode.source - if fieldnode.virtual: - self.rebuild_virtual(op.suboperations, fieldnode) - gop = self._guard_for_node(node) - op.suboperations.append(gop) - op.suboperations.append(ResOperation(rop.SETARRAYITEM_GC, - [node.source, ConstInt(field), box], None, descr)) - op.suboperations.append(op_fail) - op.args = self.new_arguments(op) - return op + # XXX in general, it's probably not correct, but should work + # because we always pass frame anyway + if rebuild: + for node, d in self.additional_stores.iteritems(): + for field, fieldnode in d.iteritems(): + if fieldnode.virtual: + self.rebuild_virtual(ops, fieldnode) + gop = self._guard_for_node(node) + ops.append(gop) + ops.append(ResOperation(rop.SETFIELD_GC, + [node.source, fieldnode.source], None, field)) + for node, d in self.additional_setarrayitems.iteritems(): + for field, (fieldnode, descr) in d.iteritems(): + box = fieldnode.source + if fieldnode.virtual: + self.rebuild_virtual(ops, fieldnode) + gop = self._guard_for_node(node) + ops.append(gop) + ops.append(ResOperation(rop.SETARRAYITEM_GC, + [node.source, ConstInt(field), box], None, descr)) def optimize_operations(self): self.additional_stores = {} @@ -205,6 +214,8 @@ newoperations.append(op) continue # default handler + if op.opnum == rop.FAIL or op.opnum == rop.JUMP: + self.rebuild_virtuals(newoperations, op.args) op = op.clone() op.args = self.new_arguments(op) if op.is_always_pure(): @@ -371,7 +382,7 @@ d = spec.additional_setarrayitems.setdefault(instnode, {}) d[field] = (fieldnode, op.descr) return True - + class SimpleVirtualOpt(object): @staticmethod def optimize_new_with_vtable(op, spec): Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/pyjitpl.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/pyjitpl.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/pyjitpl.py Mon Jun 1 20:36:15 2009 @@ -1068,7 +1068,9 @@ assert resbox is None or isinstance(resbox, Box) # record the operation if not constant-folded away if not canfold: - self.history.record(opnum, argboxes, resbox, descr) + self.history.record(opnum, argboxes, resbox, descr, + self.framestack[-1].pc, + self.framestack[-1].jitcode.name) return resbox def _interpret(self): Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_basic.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_basic.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_basic.py Mon Jun 1 20:36:15 2009 @@ -749,7 +749,6 @@ def test_r_dict(self): py.test.skip('in-progress') - class TestLLtype(BasicTests, LLJitMixin): def test_oops_on_nongc(self): Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py Mon Jun 1 20:36:15 2009 @@ -195,7 +195,7 @@ i3 = getfield_gc(p0, descr=field_desc) # ^^^ this one as well guard_true(i3) - fail() + fail(p0) """ expected = """ [p0] @@ -205,7 +205,7 @@ guard_nonvirtualized(p0) fail() setfield_gc(p0, i2, descr=field_desc) - fail() + fail(p0) """ self.assert_equal(self.optimize(pre_op, [SimpleVirtualizableOpt()]), expected) @@ -262,7 +262,7 @@ i2 = int_add(i1, i1) i3 = int_is_true(i2) guard_true(i3) - fail() + fail(p0) """ pre_op = self.parse(pre_op) expected = """ @@ -274,7 +274,7 @@ guard_nonvirtualized(p1) fail() setarrayitem_gc(p1, 0, i0, descr=array_descr) - fail() + fail(p0) """ self.assert_equal(self.optimize(pre_op, [SimpleVirtualizableOpt()]), expected) @@ -292,7 +292,7 @@ i4 = int_add(i2, i3) i5 = int_is_true(i4) guard_true(i5) - fail() + fail(p0) """ expected = """ [p0, i0, i1] @@ -303,7 +303,7 @@ guard_nonvirtualized(p1) fail() setarrayitem_gc(p1, 0, i1, descr=array_descr) - fail() + fail(p0) """ self.assert_equal(self.optimize(pre_op, [SimpleVirtualizableOpt()]), expected) @@ -477,6 +477,30 @@ SimpleVirtualOpt()]), expected) + + def test_virtualizable_fail_forces(self): + pre_op = """ + [p0] + p3 = new_with_vtable(ConstClass(node_vtable)) + guard_nonvirtualized(p0, vdesc=vdesc) + fail() + p1 = getfield_gc(p0, descr=list_node_desc) + setarrayitem_gc(p1, 0, p3) + fail(p0) + """ + expected = """ + [p0] + p1 = getfield_gc(p0, descr=list_node_desc) + p3 = new_with_vtable(ConstClass(node_vtable)) + guard_nonvirtualized(p1) + fail() + setarrayitem_gc(p1, 0, p3) + fail(p0) + """ + self.assert_equal(self.optimize(pre_op, [SimpleVirtualizableOpt(), + SimpleVirtualOpt()]), + expected) + def test_virtual_without_vtable(self): pre_op = """ [i1] From fijal at codespeak.net Tue Jun 2 08:02:22 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Tue, 2 Jun 2009 08:02:22 +0200 (CEST) Subject: [pypy-svn] r65534 - pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/doc Message-ID: <20090602060222.A1965169E94@codespeak.net> Author: fijal Date: Tue Jun 2 08:02:20 2009 New Revision: 65534 Added: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/doc/virtualizables.txt - copied, changed from r65516, pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/doc/simple_virtualizables.txt Removed: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/doc/simple_virtualizables.txt Log: My brain dump how to make virtualizables work correctly with growing fields Copied: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/doc/virtualizables.txt (from r65516, pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/doc/simple_virtualizables.txt) ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/doc/simple_virtualizables.txt (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/doc/virtualizables.txt Tue Jun 2 08:02:20 2009 @@ -1,11 +1,7 @@ Simplified virtualizables ========================= -As a first step for speeding up code, we plan to implement simplified version -of virtualizables. Simplified in a sense that it won't support virtuals stored -on virtualizables. - -For those unaware: +Let's start with some definitions: * Virtuals are objects which are known not to escape from jit code, hence they're not allocated at all and their fields are stored in registers and or @@ -16,9 +12,93 @@ modify from outside the jit code. So the jit knows where they're and have a way to reconstruct them if necessary. -The way to implement virtualizables would be as follows: +A couple of observations, in terms of a python interpreter: + +Usually we pass a virtualizable around everywhere (this is a frame +object) which is stored on a framestack and allocated before each next +call to portal (portal is a bytecode dispatch loop). Almost everything +is stored on top of this virtualizable. There is a valuestack and locals +which usually store most commonly accessed variables. + +A typical loop, for example for adding integers (the best benchmark ever) +will look like this: + +for a code: + + while i < 10000: + i += 1 + +v1 = getfield_gc(frame, "locals") +v2 = getarrayitem_gc(v1, 0) # or some other element +v3 = getfield_gc(frame, "valuestack") +setarrayitem_gc(v3, 0, v2) +setarrayitem_gc(v3, 1, Constant(1)) +v4 = getarrayitem_gc(v3, 0) +v5 = getarrayitem_gc(v3, 1) +i0 = getfield_gc(v4, "intval") +i1 = getfield_gc(v5, "intval") +v3 = new_with_vtable(W_IntObject) +i2 = int_add(i0, i1) +setfield_gc(v3, "intval", i2) +.... store into valuestack, load and store in locals + +clearly, what we really want is: + +i1 = int_add(i0, 1) + +In order to achieve this, we need: + +* Make sure that frame is not used + +* Make sure that things on the frame are virtual, so they don't get + allocated until needed. + +So the real loop will pass around virtualizable and intval of local variable i. +We can achieve that by unpacking W_IntObject read from locals before the loop +and carefully rebuilding this for each guard failure, by a small bit of +assembler code. + +Problem one: what if we access this from a call or somewhere else? +------------------------------------------------------------------- + +This is the general problem with virtualizables, what if one has a reference +to that object and will choose to use it in place where we have things on +stack or not allocated at all? + +1. We store a small piece of assembler code as a function pointer inside + a virtualizable. This is I think simpler than having complex rebuild + info kept together along the chain. If someone accesses the frame, + this code will run and rebuild what is necessary. If this happens, there + are two possiblities: + +2. We check after the call (guard_nonvirtualized, but we need to put it + a bit differently) that frame was not accessed and if it was, exit the + jit. + +Problem two: what if we grow more elements during bridges? +---------------------------------------------------------- + +The problem is for such code: + + while i < 10000: + if i % 2: + i += a + else: + i += b + +Now the first loop is compiled and when the second part (a bridge) is compiled, +we end up with non-matching virtualizables. To avoid that, we need to pass +more arguments to the loop that usually anticipated. Note that this is not +a big deal if we're careful enough (for x86) since we can put more stuff on +the stack if we update esp register. We'll use ebp as a base for stack +operations, so we're free to change value of esp any time we want. +So we will end up with things like this: + +(%ebp), (%ebp+4), (%ebp+8) - original args +(%ebp+c), %(ebp+10) - temporary values +(%ebp+14) - additional value -* During translation, all field accesses to virtualizables are replace by - calls to helpers that read/write fields via the jit. +and we'll update esp by +4 -XXX +This also solves the problem of moving around vars when we need to update +esp because of jump. good. From cfbolz at codespeak.net Tue Jun 2 13:29:11 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Tue, 2 Jun 2009 13:29:11 +0200 (CEST) Subject: [pypy-svn] r65535 - pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp Message-ID: <20090602112911.306C7169E96@codespeak.net> Author: cfbolz Date: Tue Jun 2 13:29:08 2009 New Revision: 65535 Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/codewriter.py Log: Fix nonsense checked in in revision 65504. Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/codewriter.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/codewriter.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/codewriter.py Tue Jun 2 13:29:08 2009 @@ -932,10 +932,7 @@ pure = False if op.opname == "direct_call": func = getattr(get_funcobj(op.args[0].value), '_callable', None) - if func is None: - pure = getattr(func, "_pure_function_", False) - else: - pure = False # a portal, likely + pure = getattr(func, "_pure_function_", False) try: canraise = self.raise_analyzer.can_raise(op) except lltype.DelayedPointer: From cfbolz at codespeak.net Tue Jun 2 13:35:14 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Tue, 2 Jun 2009 13:35:14 +0200 (CEST) Subject: [pypy-svn] r65536 - pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test Message-ID: <20090602113514.1980F169E96@codespeak.net> Author: cfbolz Date: Tue Jun 2 13:35:13 2009 New Revision: 65536 Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_basic.py Log: Armin told me that this test makes no sense. Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_basic.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_basic.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_basic.py Tue Jun 2 13:35:13 2009 @@ -276,27 +276,6 @@ assert res == 42 self.check_history_(int_add=0, int_mul=0, call=0) - def test_residual_call_pure_exception(self): - py.test.skip("fix this") - def externfn(x, y): - if x == 0: - raise IndexError - return x * y - externfn._pure_function_ = True - def f(n): - try: - n = hint(n, promote=True) - return externfn(n, n+1) - except IndexError: - return 5 - res = self.interp_operations(f, [6]) - assert res == 42 - self.check_history_(int_add=0, int_mul=0, call=0) - res = self.interp_operations(f, [0]) - assert res == 5 - # XXX what should go to the next line? - # self.check_history_(int_add=0, int_mul=0, call=0) - def test_constant_across_mp(self): myjitdriver = JitDriver(greens = [], reds = ['n']) class X(object): From cfbolz at codespeak.net Tue Jun 2 13:36:36 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Tue, 2 Jun 2009 13:36:36 +0200 (CEST) Subject: [pypy-svn] r65537 - in pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp: . test Message-ID: <20090602113636.C115E169F1E@codespeak.net> Author: cfbolz Date: Tue Jun 2 13:36:36 2009 New Revision: 65537 Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py Log: Tiny enhancement to optimize2: if an ooisnull/oononnull are performed after a guard_class on a variable, we remove them. Such checks seem to be common. Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/optimize2.py Tue Jun 2 13:36:36 2009 @@ -255,6 +255,26 @@ instnode.cls = op.args[1] return False + @staticmethod + def optimize_oononnull(op, spec): + # very simple optimization: if the class of something is known (via + # guard_class) the thing cannot be a NULL + instnode = spec.getnode(op.args[0]) + if instnode.cls is None: + return False + spec.nodes[op.result] = InstanceNode(ConstInt(1), const=True) + return True + + @staticmethod + def optimize_ooisnull(op, spec): + # very simple optimization: if the class of something is known (via + # guard_class) the thing cannot be a NULL + instnode = spec.getnode(op.args[0]) + if instnode.cls is None: + return False + spec.nodes[op.result] = InstanceNode(ConstInt(0), const=True) + return True + class SimpleVirtualizableOpt(object): @staticmethod def find_nodes_setfield_gc(op, spec): Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py Tue Jun 2 13:36:36 2009 @@ -166,6 +166,29 @@ [ConsecutiveGuardClassRemoval()]), expected) + def test_remove_ooisnull_after_guard(self): + pre_op = """ + [p0] + guard_class(p0, ConstClass(node_vtable)) + fail() + i0 = ooisnull(p0) + guard_false(i0) + fail() + i1 = oononnull(p0) + guard_true(i1) + fail() + guard_class(p0, ConstClass(node_vtable)) + fail() + """ + expected = """ + [p0] + guard_class(p0, ConstClass(node_vtable)) + fail() + """ + self.assert_equal(self.optimize(pre_op, + [ConsecutiveGuardClassRemoval()]), + expected) + def test_basic_virtualizable(self): pre_op = """ [p0] From david at codespeak.net Tue Jun 2 13:52:46 2009 From: david at codespeak.net (david at codespeak.net) Date: Tue, 2 Jun 2009 13:52:46 +0200 (CEST) Subject: [pypy-svn] r65538 - in pypy/branch/io-lang/pypy/lang/io: . test Message-ID: <20090602115246.B8EF0169F08@codespeak.net> Author: david Date: Tue Jun 2 13:52:46 2009 New Revision: 65538 Modified: pypy/branch/io-lang/pypy/lang/io/model.py pypy/branch/io-lang/pypy/lang/io/test/test_map.py pypy/branch/io-lang/pypy/lang/io/test/test_object.py Log: Fixed scoping issue with nested contexts Modified: pypy/branch/io-lang/pypy/lang/io/model.py ============================================================================== --- pypy/branch/io-lang/pypy/lang/io/model.py (original) +++ pypy/branch/io-lang/pypy/lang/io/model.py Tue Jun 2 13:52:46 2009 @@ -199,7 +199,7 @@ w_result = w_method.apply(space, w_receiver, self, w_context) if self.next: #TODO: optimize - return self.next.eval(space, w_result, w_receiver) + return self.next.eval(space, w_result, w_context) else: return w_result @@ -239,7 +239,7 @@ w_locals.slots['call'] = w_call w_call.slots['message'] = w_message - return self.body.eval(space, w_locals, w_context) + return self.body.eval(space, w_locals, w_locals) def clone(self): Modified: pypy/branch/io-lang/pypy/lang/io/test/test_map.py ============================================================================== --- pypy/branch/io-lang/pypy/lang/io/test/test_map.py (original) +++ pypy/branch/io-lang/pypy/lang/io/test/test_map.py Tue Jun 2 13:52:46 2009 @@ -104,6 +104,19 @@ res,space = interpret(inp) value = sorted([(x.items[0].value, x.items[1].value) for x in res.items]) assert value == [('1', 12345), ('2', 99), ('3', 3), ('4', 234)] + +def test_map_foreach_leaks(): + inp = """b := Map clone do( + atPut("1", 12345) + atPut("2", 99) + atPut("3", 3) + atPut("4", 234) + ) + c := list() + b foreach(key, value, c append(list(key, value))); list(key,value)""" + res,space = interpret(inp) + l = [x.value for x in res.items] + assert l == ['4', 234] def test_keys(): inp = """b := Map clone do( @@ -115,4 +128,36 @@ b keys""" res, space = interpret(inp) keys = sorted([x.value for x in res.items]) - assert keys == ['1', '2', '3', '4'] \ No newline at end of file + assert keys == ['1', '2', '3', '4'] + +def test_do_on_map_sum(): + inp = """ + Map do( + sum := method( + s := 0 + self foreach(key, value, s := s + value) + // debugger + s + ) + ) + Map clone atPut("a", 123) atPut("b", 234) atPut("c", 345) sum""" + res, _ = interpret(inp) + assert isinstance(res, W_Number) + assert res.value == 702 + + +def test_map_asObject_inline(): + inp = """ + Map do( + asObject := method( + o := Object clone + self foreach(k, v, o setSlot(k, getSlot("v"))) + o + ) + ) + Map clone atPut("1", 12345) atPut("2", 99) atPut("3", 3) atPut("4", 234) asObject""" + res, space = interpret(inp) + assert res.slots['1'].value == 12345 + assert res.slots['2'].value == 99 + assert res.slots['3'].value == 3 + assert res.slots['4'].value == 234 Modified: pypy/branch/io-lang/pypy/lang/io/test/test_object.py ============================================================================== --- pypy/branch/io-lang/pypy/lang/io/test/test_object.py (original) +++ pypy/branch/io-lang/pypy/lang/io/test/test_object.py Tue Jun 2 13:52:46 2009 @@ -1,5 +1,5 @@ from pypy.lang.io.parserhack import parse, interpret -from pypy.lang.io.model import W_Object, W_Message +from pypy.lang.io.model import W_Object, W_Message, W_Number import py.test @@ -9,6 +9,18 @@ assert res.slots['a'].value == 23 assert res.value == 4 +def test_do_on_map(): + inp = """ + Map do( + get := method(i, + self at(i) + ) + ) + Map clone atPut("a", 123) atPut("b", 234) atPut("c", 345) get("b")""" + res, _ = interpret(inp) + assert isinstance(res, W_Number) + assert res.value == 234 + def test_object_do_multiple_slots(): inp = 'Object do(a := 23; b := method(a + 5); a := 1); Object b' res, space = interpret(inp) From david at codespeak.net Tue Jun 2 13:53:23 2009 From: david at codespeak.net (david at codespeak.net) Date: Tue, 2 Jun 2009 13:53:23 +0200 (CEST) Subject: [pypy-svn] r65539 - pypy/branch/io-lang/pypy/lang/io Message-ID: <20090602115323.56AFF169F51@codespeak.net> Author: david Date: Tue Jun 2 13:53:21 2009 New Revision: 65539 Modified: pypy/branch/io-lang/pypy/lang/io/object.py Log: App level method to open the python debugger Modified: pypy/branch/io-lang/pypy/lang/io/object.py ============================================================================== --- pypy/branch/io-lang/pypy/lang/io/object.py (original) +++ pypy/branch/io-lang/pypy/lang/io/object.py Tue Jun 2 13:53:21 2009 @@ -51,7 +51,7 @@ @register_method('Object', 'do') def w_object_do(space, w_target, w_message, w_context): - w_message.arguments[0].eval(space, w_target, w_context) + w_message.arguments[0].eval(space, w_target, w_target) return w_target @register_method('Object', '', unwrap_spec=[object, object]) @@ -65,4 +65,10 @@ @register_method('Object', '-', unwrap_spec=[object, float]) def object_minus(space, w_target, argument): - return W_Number(space, -argument) \ No newline at end of file + return W_Number(space, -argument) + + at register_method('Object', 'debugger') +def object_message(space, w_target, w_message, w_context): + import pdb + pdb.set_trace() + return w_target From antocuni at codespeak.net Tue Jun 2 13:58:07 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 2 Jun 2009 13:58:07 +0200 (CEST) Subject: [pypy-svn] r65540 - pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/test Message-ID: <20090602115807.2CD21169F51@codespeak.net> Author: antocuni Date: Tue Jun 2 13:58:06 2009 New Revision: 65540 Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/test/test_basic.py Log: skip this test, as it can be run only after translation Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/test/test_basic.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/test/test_basic.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/test/test_basic.py Tue Jun 2 13:58:06 2009 @@ -38,6 +38,7 @@ test_long_long = skip test_free_object = skip test_stopatxpolicy = skip + test_residual_call_pure = skip def test_fielddescr_ootype(): From antocuni at codespeak.net Tue Jun 2 14:02:15 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 2 Jun 2009 14:02:15 +0200 (CEST) Subject: [pypy-svn] r65541 - pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli Message-ID: <20090602120215.75142169F4E@codespeak.net> Author: antocuni Date: Tue Jun 2 14:02:14 2009 New Revision: 65541 Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/method.py Log: add the "nocast" option, to avoid unneeded casts when doing {get,set}field_gc: so far boxes were stored with type System.Object, as they needed to be casted before accessing the fields. With "nocast", we skim over all operations to compute the exact type to store the variable without needing to do any cast. Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/method.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/method.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/cli/method.py Tue Jun 2 14:02:14 2009 @@ -36,7 +36,10 @@ class __extend__(AbstractValue): __metaclass__ = extendabletype - def getCliType(self): + def getCliType(self, meth): + if self in meth.box2type: + return meth.box2type[self] + if self.type == history.INT: return dotnet.typeof(System.Int32) elif self.type == history.OBJ: @@ -104,7 +107,7 @@ self.index = index self.cliType = cliType - def getCliType(self): + def getCliType(self, meth): return self.cliType def load(self, meth): @@ -129,8 +132,9 @@ class Method(object): operations = [] # overwritten at the end of the module - tailcall = True debug = False + tailcall = True + nocast = True def __init__(self, cpu, name, loop): self.setoptions() @@ -159,6 +163,9 @@ logger.eventually_log_operations(loop.inputargs, loop.operations, None, compute_unique_id(loop)) # ---- + self.box2type = {} + if self.nocast: + self.compute_types() self.emit_load_inputargs() self.emit_preamble() self.emit_operations(loop.operations) @@ -179,17 +186,38 @@ def setoptions(self): opts = os.environ.get('PYPYJITOPT') if opts is None: - pass - parts = opts.split() + return + parts = opts.split(' ') for part in parts: name, value = self._parseopt(part) if name == 'debug': self.debug = value elif name == 'tailcall': self.tailcall = value + elif name == 'nocast': + self.nocast = value else: os.write(2, 'Warning: invalid option name: %s\n' % name) + def compute_types(self): + # XXX: look also in op.suboperations + box2classes = {} # box --> [ootype.Class] + for op in self.loop.operations: + if op.opnum in (rop.GETFIELD_GC, rop.SETFIELD_GC): + box = op.args[0] + descr = op.descr + assert isinstance(descr, runner.FieldDescr) + box2classes.setdefault(box, []).append(descr.selfclass) + + for box, classes in box2classes.iteritems(): + cls = classes[0] + for cls2 in classes[1:]: + if ootype.subclassof(cls, cls2): + cls = cls2 + else: + assert ootype.subclassof(cls2, cls) + self.box2type[box] = dotnet.class2type(cls) + def finish_code(self): delegatetype = dotnet.typeof(LoopDelegate) # initialize the array of genconsts @@ -218,7 +246,7 @@ try: return self.boxes[box] except KeyError: - v = self.il.DeclareLocal(box.getCliType()) + v = self.il.DeclareLocal(box.getCliType(self)) self.boxes[box] = v return v @@ -275,7 +303,7 @@ self.emit_debug("executing: " + self.name) i = 0 for box in self.loop.inputargs: - self.load_inputarg(i, box.type, box.getCliType()) + self.load_inputarg(i, box.type, box.getCliType(self)) box.store(self) i+=1 @@ -366,7 +394,7 @@ # store the latest values i = 0 for box in op.args: - self.store_inputarg(i, box.type, box.getCliType(), box) + self.store_inputarg(i, box.type, box.getCliType(self), box) i+=1 def emit_guard_bool(self, op, opcode): @@ -508,8 +536,10 @@ assert isinstance(descr, runner.FieldDescr) clitype = descr.get_self_clitype() fieldinfo = descr.get_field_info() - op.args[0].load(self) - self.il.Emit(OpCodes.Castclass, clitype) + obj = op.args[0] + obj.load(self) + if obj.getCliType(self) is not clitype: + self.il.Emit(OpCodes.Castclass, clitype) self.il.Emit(OpCodes.Ldfld, fieldinfo) self.store_result(op) @@ -520,8 +550,10 @@ assert isinstance(descr, runner.FieldDescr) clitype = descr.get_self_clitype() fieldinfo = descr.get_field_info() - op.args[0].load(self) - self.il.Emit(OpCodes.Castclass, clitype) + obj = op.args[0] + obj.load(self) + if obj.getCliType(self) is not clitype: + self.il.Emit(OpCodes.Castclass, clitype) op.args[1].load(self) self.il.Emit(OpCodes.Stfld, fieldinfo) From antocuni at codespeak.net Tue Jun 2 14:21:03 2009 From: antocuni at codespeak.net (antocuni at codespeak.net) Date: Tue, 2 Jun 2009 14:21:03 +0200 (CEST) Subject: [pypy-svn] r65542 - in pypy/branch/pyjitpl5-experiments/pypy/rpython: ootypesystem test Message-ID: <20090602122103.14FBD168455@codespeak.net> Author: antocuni Date: Tue Jun 2 14:20:59 2009 New Revision: 65542 Modified: pypy/branch/pyjitpl5-experiments/pypy/rpython/ootypesystem/rclass.py pypy/branch/pyjitpl5-experiments/pypy/rpython/test/test_rclass.py Log: don't crash when trying to compute the hash of a null instance on ootype Modified: pypy/branch/pyjitpl5-experiments/pypy/rpython/ootypesystem/rclass.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/rpython/ootypesystem/rclass.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/rpython/ootypesystem/rclass.py Tue Jun 2 14:20:59 2009 @@ -570,6 +570,8 @@ def ll_inst_hash(ins): + if not ins: + return 0 cached = ins._hash_cache_ if cached == 0: cached = ins._hash_cache_ = ootype.ooidentityhash(ins) Modified: pypy/branch/pyjitpl5-experiments/pypy/rpython/test/test_rclass.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/rpython/test/test_rclass.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/rpython/test/test_rclass.py Tue Jun 2 14:20:59 2009 @@ -661,6 +661,18 @@ return a.revealconst(1) + b.revealconst(2) + a.revealconst(3) assert self.interpret(fn, []) == 3 + 8 + 9 + def test_hash_of_none(self): + class A: + pass + def fn(x): + if x: + obj = A() + else: + obj = None + return hash(obj) + res = self.interpret(fn, [0]) + assert res == 0 + class TestLltype(BaseTestRclass, LLRtypeMixin): From cfbolz at codespeak.net Tue Jun 2 17:29:50 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Tue, 2 Jun 2009 17:29:50 +0200 (CEST) Subject: [pypy-svn] r65543 - pypy/trunk/pypy/objspace/std/test Message-ID: <20090602152950.0E2FF169F6D@codespeak.net> Author: cfbolz Date: Tue Jun 2 17:29:48 2009 New Revision: 65543 Modified: pypy/trunk/pypy/objspace/std/test/test_typeobject.py Log: A skipped test: The __dict__ attribute of our types returns a dict proxy object that is a copy of the real type dict. Thus it is not updated when the type dict changes. 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 Tue Jun 2 17:29:48 2009 @@ -915,6 +915,15 @@ return 0 raises(TypeError, X) + def test_dictproxy_is_updated(self): + py.test.skip("fix me") + class A(object): + x = 1 + d = A.__dict__ + assert d["x"] == 1 + A.y = 2 + assert d["y"] == 2 + class AppTestMutableBuiltintypes: From cfbolz at codespeak.net Tue Jun 2 17:37:56 2009 From: cfbolz at codespeak.net (cfbolz at codespeak.net) Date: Tue, 2 Jun 2009 17:37:56 +0200 (CEST) Subject: [pypy-svn] r65544 - pypy/branch/pyjitpl5-experiments/pypy/objspace/std Message-ID: <20090602153756.49C61169F82@codespeak.net> Author: cfbolz Date: Tue Jun 2 17:37:55 2009 New Revision: 65544 Modified: pypy/branch/pyjitpl5-experiments/pypy/objspace/std/typeobject.py Log: I think this should get rid of the remaining dict lookups on the type in the residual code for an attribute access. It's not necessarily a good idea, as new bridges will be made every time someone changes a counter on a class. Modified: pypy/branch/pyjitpl5-experiments/pypy/objspace/std/typeobject.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/objspace/std/typeobject.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/objspace/std/typeobject.py Tue Jun 2 17:37:55 2009 @@ -7,7 +7,7 @@ from pypy.objspace.std.dictproxyobject import W_DictProxyObject from pypy.rlib.objectmodel import we_are_translated from pypy.rlib.objectmodel import current_object_addr_as_int -from pypy.rlib.jit import hint +from pypy.rlib.jit import hint, purefunction from pypy.rlib.rarithmetic import intmask, r_uint from copy_reg import _HEAPTYPE @@ -189,6 +189,14 @@ if version_tag is None: tup = w_self._lookup_where(name) return tup + w_self = hint(w_self, promote=True) + name = hint(name, promote=True) + version_tag = hint(version_tag, promote=True) + return w_self._pure_lookup_where_with_method_cache(name, version_tag) + + @purefunction + def _pure_lookup_where_with_method_cache(w_self, name, version_tag): + space = w_self.space SHIFT = r_uint.BITS - space.config.objspace.std.methodcachesizeexp version_tag_as_int = current_object_addr_as_int(version_tag) # ^^^Note: if the version_tag object is moved by a moving GC, the From fijal at codespeak.net Wed Jun 3 01:44:51 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 3 Jun 2009 01:44:51 +0200 (CEST) Subject: [pypy-svn] r65547 - pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86 Message-ID: <20090602234451.E7D27168554@codespeak.net> Author: fijal Date: Wed Jun 3 01:44:48 2009 New Revision: 65547 Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/regalloc.py Log: Use ebp instead of esp for a basis of frame computations. Simplifies some stuff, but no big win so far. Expect more to come :-) Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/assembler.py Wed Jun 3 01:44:48 2009 @@ -177,8 +177,7 @@ mc.ADD(esp, imm32(tree._x86_stack_depth * WORD)) mc.done() for op, pos in self.jumps_to_look_at: - if op.jump_target._x86_stack_depth < tree._x86_stack_depth: - # XXX do a dumb thing + if op.jump_target._x86_stack_depth != tree._x86_stack_depth: tl = op.jump_target self.patch_jump(pos, tl._x86_compiled, tl.arglocs, tl.arglocs, tree._x86_stack_depth, tl._x86_stack_depth) @@ -197,9 +196,9 @@ def assemble_bootstrap_code(self, jumpaddr, arglocs, framesize): self.make_sure_mc_exists() addr = self.mc.tell() - if self.gcrootmap: - self.mc.PUSH(ebp) - self.mc.MOV(ebp, esp) + #if self.gcrootmap: + self.mc.PUSH(ebp) + self.mc.MOV(ebp, esp) self.mc.SUB(esp, imm(framesize * WORD)) # This uses XCHG to put zeroes in fail_boxes after reading them, # just in case they are pointers. @@ -606,51 +605,17 @@ locs = [loc.position for loc in newlocs if isinstance(loc, MODRM)] assert locs == sorted(locs) # - if newdepth != olddepth: - mc2 = self.mcstack.next_mc() - pos = mc2.tell() - diff = olddepth - newdepth - for loc in newlocs: - if isinstance(loc, MODRM): - has_modrm = True - break - else: - has_modrm = False - if diff > 0: - if has_modrm: - extra_place = stack_pos(olddepth - 1) # this is unused - mc2.MOV(extra_place, eax) - for i in range(len(newlocs) -1, -1, -1): - loc = newlocs[i] - if isinstance(loc, MODRM): - mc2.MOV(eax, loc) - mc2.MOV(stack_pos(loc.position + diff), eax) - mc2.MOV(eax, extra_place) - mc2.ADD(esp, imm32((diff) * WORD)) - else: - mc2.SUB(esp, imm32((-diff) * WORD)) - if has_modrm: - extra_place = stack_pos(newdepth - 1) # this is unused - mc2.MOV(extra_place, eax) - for i in range(len(newlocs)): - loc = newlocs[i] - if isinstance(loc, MODRM): - # diff is negative! - mc2.MOV(eax, stack_pos(loc.position - diff)) - mc2.MOV(loc, eax) - mc2.MOV(eax, extra_place) - mc2.JMP(rel32(new_pos)) - self.mcstack.give_mc_back(mc2) - else: - pos = new_pos mc = codebuf.InMemoryCodeBuilder(old_pos, old_pos + MachineCodeBlockWrapper.MC_SIZE) - mc.JMP(rel32(pos)) + mc.SUB(esp, imm(WORD * (newdepth - olddepth))) + mc.JMP(rel32(new_pos)) mc.done() def genop_discard_jump(self, op, locs): targetmp = op.jump_target - self.jumps_to_look_at.append((op, self.mc.tell())) + if op.jump_target is not self.tree: + self.jumps_to_look_at.append((op, self.mc.tell())) + self.mc.ADD(esp, imm(0)) self.mc.JMP(rel32(targetmp._x86_compiled)) def genop_guard_guard_true(self, op, ign_1, addr, locs, ign_2): @@ -745,8 +710,8 @@ self.mc.ADD(esp, imm32(0)) guard_index = self.cpu.make_guard_index(op) self.mc.MOV(eax, imm(guard_index)) - if self.gcrootmap: - self.mc.POP(ebp) + #if self.gcrootmap: + self.mc.POP(ebp) self.mc.RET() def generate_ovf_set(self): @@ -784,14 +749,14 @@ self.mc.PUSH(loc) else: # we need to add a bit, ble - self.mc.PUSH(stack_pos(loc.position + extra_on_stack)) + self.mc.PUSH(stack_pos(loc.position)) extra_on_stack += 1 if isinstance(op.args[0], Const): x = rel32(op.args[0].getint()) else: x = arglocs[0] if isinstance(x, MODRM): - x = stack_pos(x.position + extra_on_stack) + x = stack_pos(x.position) self.mc.CALL(x) self.mark_gc_roots(extra_on_stack) self.mc.ADD(esp, imm(WORD * extra_on_stack)) Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/regalloc.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/regalloc.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/x86/regalloc.py Wed Jun 3 01:44:48 2009 @@ -315,9 +315,9 @@ i += 1 assert not self.reg_bindings jmp = operations[-1] - if jmp.opnum == rop.JUMP and jmp.jump_target is not self.tree: - self.max_stack_depth = max(jmp.jump_target._x86_stack_depth, - self.max_stack_depth) + #if jmp.opnum == rop.JUMP and jmp.jump_target is not self.tree: + # self.max_stack_depth = max(jmp.jump_target._x86_stack_depth, + # self.max_stack_depth) self.max_stack_depth = max(self.max_stack_depth, self.current_stack_depth + 1) @@ -1155,9 +1155,9 @@ # write the code that moves the correct value into 'res', in two # steps: generate a pair PUSH (immediately) / POP (later) if isinstance(src, MODRM): - src = stack_pos(src.position + extra_on_stack) + src = stack_pos(src.position) if isinstance(res, MODRM): - res = stack_pos(res.position + extra_on_stack) + res = stack_pos(res.position) self.assembler.regalloc_push(src) later_pops.append(res) extra_on_stack += 1 @@ -1180,7 +1180,7 @@ oplist[num] = value def stack_pos(i): - res = mem(esp, WORD * i) + res = mem(ebp, -WORD * (1 + i)) res.position = i return res From fijal at codespeak.net Wed Jun 3 03:05:25 2009 From: fijal at codespeak.net (fijal at codespeak.net) Date: Wed, 3 Jun 2009 03:05:25 +0200 (CEST) Subject: [pypy-svn] r65548 - pypy/branch/pyjitpl5-experiments/pypy/rpython Message-ID: <20090603010525.E4034169E28@codespeak.net> Author: fijal Date: Wed Jun 3 03:05:22 2009 New Revision: 65548 Modified: pypy/branch/pyjitpl5-experiments/pypy/rpython/llinterp.py Log: disable tracer by default, it causes a lot of problems on my computer with startup time. Modified: pypy/branch/pyjitpl5-experiments/pypy/rpython/llinterp.py ============================================================================== --- pypy/branch/pyjitpl5-experiments/pypy/rpython/llinterp.py (original) +++ pypy/branch/pyjitpl5-experiments/pypy/rpython/llinterp.py Wed Jun 3 03:05:22 2009 @@ -1186,6 +1186,7 @@ class Tracer(object): Counter = 0 file = None + TRACE = False HEADER = """