[pypy-commit] pypy py3k: s/maxint/maxsize/g in applevel tests
Author: Amaury Forgeot d'Arc Branch: py3k Changeset: r59208:ca88ab756b58 Date: 2012-12-02 10:02 +0100 http://bitbucket.org/pypy/pypy/changeset/ca88ab756b58/ Log:s/maxint/maxsize/g in applevel tests diff --git a/pypy/objspace/std/test/test_intobject.py b/pypy/objspace/std/test/test_intobject.py --- a/pypy/objspace/std/test/test_intobject.py +++ b/pypy/objspace/std/test/test_intobject.py @@ -321,7 +321,7 @@ def test_int_largenums(self): import sys -for x in [-sys.maxint-1, -1, sys.maxint]: +for x in [-sys.maxsize-1, -1, sys.maxsize]: y = int(str(x)) assert y == x assert type(y) is int @@ -332,7 +332,7 @@ def test_overflow(self): import sys -n = sys.maxint + 1 +n = sys.maxsize + 1 assert isinstance(n, int) def test_pow(self): diff --git a/pypy/objspace/std/test/test_longobject.py b/pypy/objspace/std/test/test_longobject.py --- a/pypy/objspace/std/test/test_longobject.py +++ b/pypy/objspace/std/test/test_longobject.py @@ -244,7 +244,7 @@ def test_long(self): import sys -n = -sys.maxint-1 +n = -sys.maxsize-1 assert int(n) == n assert str(int(n)) == str(n) diff --git a/pypy/objspace/std/test/test_smalllongobject.py b/pypy/objspace/std/test/test_smalllongobject.py --- a/pypy/objspace/std/test/test_smalllongobject.py +++ b/pypy/objspace/std/test/test_smalllongobject.py @@ -100,7 +100,7 @@ def test_sl_add_32(self): import sys, __pypy__ -if sys.maxint == 2147483647: +if sys.maxsize == 2147483647: x = 2147483647 assert x + x == 4294967294 assert 'SmallLong' in __pypy__.internal_repr(x + x) diff --git a/pypy/objspace/std/test/test_stringformat.py b/pypy/objspace/std/test/test_stringformat.py --- a/pypy/objspace/std/test/test_stringformat.py +++ b/pypy/objspace/std/test/test_stringformat.py @@ -101,8 +101,8 @@ assert '0x0' == '%#x' % z assert '23' == '%s' % n assert '23' == '%r' % n -assert ('%d' % (-sys.maxint-1,) == '-' + str(sys.maxint+1) -== '-%d' % (sys.maxint+1,)) +assert ('%d' % (-sys.maxsize-1,) == '-' + str(sys.maxsize+1) + == '-%d' % (sys.maxsize+1,)) n = 28 m = 8 assert '1C' == '%X' % n diff --git a/pypy/objspace/std/test/test_strsliceobject.py b/pypy/objspace/std/test/test_strsliceobject.py --- a/pypy/objspace/std/test/test_strsliceobject.py +++ b/pypy/objspace/std/test/test_strsliceobject.py @@ -41,7 +41,7 @@ def test_index(self): import __pypy__, sys -m = sys.maxint +m = sys.maxsize def slice(s): return (s*3)[len(s):-len(s)] s = slice(b'abcdefghiabc' * 20) assert 'W_StringSliceObject' in __pypy__.internal_repr(s) @@ -69,7 +69,7 @@ def test_rindex(self): import __pypy__ -from sys import maxint +from sys import maxsize def slice(s): return (s*3)[len(s):-len(s)] s = slice(b"X" * 100 + b'abcdefghiabc') assert 'W_StringSliceObject' in __pypy__.internal_repr(s) @@ -77,7 +77,7 @@ assert s.rindex(b'def') == 103 assert s.rindex(b'abc') == 109 assert s.rindex(b'abc', 0, -1) == 100 -assert s.rindex(b'abc', -4*maxint, 4*maxint) == 109 +assert s.rindex(b'abc', -4*maxsize, 4*maxsize) == 109 raises(ValueError, slice(b'abcdefghiabc' * 20).rindex, b'hib') raises(ValueError, slice(b'defghiabc' + b"X" * 100).rindex, b'def', 1) raises(ValueError, slice(b'defghiabc' + b"X" * 100).rindex, b'abc', 0, -101) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: This filter is needed to avoid a conflict with options in bin/py.py
Author: Amaury Forgeot d'Arc Branch: Changeset: r59209:49fe5ba9312a Date: 2012-12-02 11:50 +0100 http://bitbucket.org/pypy/pypy/changeset/49fe5ba9312a/ Log:This filter is needed to avoid a conflict with options in bin/py.py diff --git a/pypy/tool/option.py b/pypy/tool/option.py --- a/pypy/tool/option.py +++ b/pypy/tool/option.py @@ -10,7 +10,8 @@ def get_standard_options(): config = get_pypy_config() -parser = to_optparse(config, extra_useage=extra_useage) +parser = to_optparse(config, useoptions=["objspace.*"], + extra_useage=extra_useage) return config, parser def process_options(parser, argv=None): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: unroll this function when the size of the list is constant and small
Author: Alex Gaynor Branch: Changeset: r59210:b2f7e5c13c37 Date: 2012-12-02 08:13 -0800 http://bitbucket.org/pypy/pypy/changeset/b2f7e5c13c37/ Log:unroll this function when the size of the list is constant and small diff --git a/pypy/rpython/rlist.py b/pypy/rpython/rlist.py --- a/pypy/rpython/rlist.py +++ b/pypy/rpython/rlist.py @@ -461,7 +461,6 @@ return self.r_list.recast(hop.llops, v_res) - # # # Low-level methods. These can be run for testing, but are meant to @@ -481,6 +480,8 @@ # done with it. So in the sequel we don't bother checking for overflow # when we compute "ll_length() + 1". +@jit.look_inside_iff(lambda LIST, count, item: jit.isconstant(count) and count < 15) +@jit.oopspec("newlist(count, item)") def ll_alloc_and_set(LIST, count, item): if count < 0: count = 0 @@ -492,14 +493,14 @@ check = widen(item) else: check = item -if (not malloc_zero_filled) or check: # as long as malloc it is known to zero the allocated memory avoid zeroing twice - +# as long as malloc is known to zero the allocated memory avoid zeroing +# twice +if (not malloc_zero_filled) or check: i = 0 while i < count: l.ll_setitem_fast(i, item) i += 1 return l -ll_alloc_and_set.oopspec = 'newlist(count, item)' # return a nullptr() if lst is a list of pointers it, else None. Note ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merged upstream
Author: Alex Gaynor Branch: Changeset: r59211:4a2bb783d9a6 Date: 2012-12-02 08:13 -0800 http://bitbucket.org/pypy/pypy/changeset/4a2bb783d9a6/ Log:merged upstream diff --git a/pypy/module/_random/interp_random.py b/pypy/module/_random/interp_random.py --- a/pypy/module/_random/interp_random.py +++ b/pypy/module/_random/interp_random.py @@ -3,7 +3,7 @@ from pypy.interpreter.gateway import interp2app, unwrap_spec from pypy.interpreter.baseobjspace import Wrappable from pypy.rlib.rarithmetic import r_uint, intmask -from pypy.rlib import rrandom +from pypy.rlib import rbigint, rrandom, rstring import time @@ -89,25 +89,21 @@ strerror = space.wrap("number of bits must be greater than zero") raise OperationError(space.w_ValueError, strerror) bytes = ((k - 1) // 32 + 1) * 4 -bytesarray = [0] * bytes +bytesarray = rstring.StringBuilder(bytes) for i in range(0, bytes, 4): r = self._rnd.genrand32() if k < 32: r >>= (32 - k) -bytesarray[i + 0] = r & r_uint(0xff) -bytesarray[i + 1] = (r >> 8) & r_uint(0xff) -bytesarray[i + 2] = (r >> 16) & r_uint(0xff) -bytesarray[i + 3] = (r >> 24) & r_uint(0xff) +bytesarray.append(chr(r & r_uint(0xff))) +bytesarray.append(chr((r >> 8) & r_uint(0xff))) +bytesarray.append(chr((r >> 16) & r_uint(0xff))) +bytesarray.append(chr((r >> 24) & r_uint(0xff))) k -= 32 -# XXX so far this is quadratic -w_result = space.newint(0) -w_eight = space.newint(8) -for i in range(len(bytesarray) - 1, -1, -1): -byte = bytesarray[i] -w_result = space.or_(space.lshift(w_result, w_eight), - space.newint(intmask(byte))) -return w_result +# little endian order to match bytearray assignment order +result = rbigint.rbigint.frombytes( +bytesarray.build(), 'little', signed=False) +return space.newlong_from_rbigint(result) W_Random.typedef = TypeDef("Random", diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py --- a/pypy/objspace/fake/objspace.py +++ b/pypy/objspace/fake/objspace.py @@ -143,6 +143,9 @@ def newcomplex(self, x, y): return w_some_obj() +def newlong_from_rbigint(self, x): +return w_some_obj() + def marshal_w(self, w_obj): "NOT_RPYTHON" raise NotImplementedError diff --git a/pypy/rlib/rbigint.py b/pypy/rlib/rbigint.py --- a/pypy/rlib/rbigint.py +++ b/pypy/rlib/rbigint.py @@ -2,6 +2,7 @@ from pypy.rlib.rarithmetic import ovfcheck, r_longlong, widen, is_valid_int from pypy.rlib.rarithmetic import most_neg_value_of_same_type from pypy.rlib.rfloat import isinf, isnan +from pypy.rlib.rstring import StringBuilder from pypy.rlib.debug import make_sure_not_resized, check_regular_int from pypy.rlib.objectmodel import we_are_translated, specialize from pypy.rlib import jit @@ -11,6 +12,7 @@ import math, sys SUPPORT_INT128 = hasattr(rffi, '__INT128_T') +BYTEORDER = sys.byteorder # note about digit sizes: # In division, the native integer type must be able to hold @@ -94,6 +96,12 @@ assert type(x) is type(NULLDIGIT) assert UDIGIT_MASK(x) & MASK == UDIGIT_MASK(x) +class InvalidEndiannessError(Exception): +pass + +class InvalidSignednessError(Exception): +pass + class Entry(extregistry.ExtRegistryEntry): _about_ = _check_digits def compute_result_annotation(self, s_list): @@ -261,6 +269,117 @@ # then modify the result. return _decimalstr_to_bigint(s) +@staticmethod +def frombytes(s, byteorder, signed): +if byteorder not in ('big', 'little'): +raise InvalidEndiannessError() + +if byteorder != BYTEORDER: +msb = ord(s[0]) +itr = range(len(s)-1, -1, -1) +else: +msb = ord(s[-1]) +itr = range(0, len(s)) + +sign = -1 if msb >= 0x80 and signed else 1 +accum = _widen_digit(0) +accumbits = 0 +digits = [] +carry = 1 + +for i in itr: +c = _widen_digit(ord(s[i])) +if sign == -1: +c = (0xFF ^ c) + carry +carry = c >> 8 +c &= 0xFF + +accum |= c << accumbits +accumbits += 8 +if accumbits >= SHIFT: +digits.append(_store_digit(intmask(accum & MASK))) +accum >>= SHIFT +accumbits -= SHIFT + +if accumbits: +digits.append(_store_digit(intmask(accum))) +result = rbigint(digits[:], sign) +result._normalize() +return result + +@jit.elidable +def tobytes(self, nbytes, byteorder, signed): +if byteorder not in ('big', 'little'): +raise InvalidEndiannessError() +
[pypy-commit] pypy remove-globals-in-jit: Remove outdated test
Author: Armin Rigo Branch: remove-globals-in-jit Changeset: r59212:f6e49363a0b5 Date: 2012-12-02 08:04 -0800 http://bitbucket.org/pypy/pypy/changeset/f6e49363a0b5/ Log:Remove outdated test diff --git a/pypy/jit/backend/x86/test/test_support.py b/pypy/jit/backend/x86/test/test_support.py deleted file mode 100644 --- a/pypy/jit/backend/x86/test/test_support.py +++ /dev/null @@ -1,21 +0,0 @@ - -from pypy.jit.backend.x86.support import values_array -from pypy.rpython.lltypesystem import lltype, llmemory, rffi - -def test_values_array_signed(): -ar = values_array(lltype.Signed, 50) -adr = ar.get_addr_for_num(10) -rffi.cast(rffi.CArrayPtr(lltype.Signed), adr)[0] = 42 -assert ar.getitem(10) == 42 -ar.setitem(42, 38) -adr = ar.get_addr_for_num(42) -assert rffi.cast(rffi.CArrayPtr(lltype.Signed), adr)[0] == 38 - -def test_values_array_float(): -ar = values_array(lltype.Float, 50) -adr = ar.get_addr_for_num(10) -rffi.cast(rffi.CArrayPtr(lltype.Float), adr)[0] = 42.5 -assert ar.getitem(10) == 42.5 -ar.setitem(42, 38.5) -adr = ar.get_addr_for_num(42) -assert rffi.cast(rffi.CArrayPtr(lltype.Float), adr)[0] == 38.5 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-globals-in-jit: Fix tests
Author: Armin Rigo Branch: remove-globals-in-jit Changeset: r59213:7938bad51d8c Date: 2012-12-02 08:04 -0800 http://bitbucket.org/pypy/pypy/changeset/7938bad51d8c/ Log:Fix tests diff --git a/pypy/jit/backend/x86/test/test_assembler.py b/pypy/jit/backend/x86/test/test_assembler.py --- a/pypy/jit/backend/x86/test/test_assembler.py +++ b/pypy/jit/backend/x86/test/test_assembler.py @@ -32,6 +32,12 @@ assert num == 0x1C3 return FakeFailDescr() +def gc_clear_extra_threshold(self): +pass + +def get_failargs_limit(self): +return 1000 + class FakeMC: def __init__(self): self.content = [] diff --git a/pypy/jit/backend/x86/test/test_gc_integration.py b/pypy/jit/backend/x86/test/test_gc_integration.py --- a/pypy/jit/backend/x86/test/test_gc_integration.py +++ b/pypy/jit/backend/x86/test/test_gc_integration.py @@ -51,6 +51,7 @@ _record_constptrs = GcLLDescr_framework._record_constptrs.im_func rewrite_assembler = GcLLDescr_framework.rewrite_assembler.im_func +getframedescrs= GcLLDescr_framework.getframedescrs.im_func class TestRegallocDirectGcIntegration(object): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Fix these tests
Author: Armin Rigo Branch: Changeset: r59214:892ba424789f Date: 2012-12-02 09:25 -0800 http://bitbucket.org/pypy/pypy/changeset/892ba424789f/ Log:Fix these tests diff --git a/pypy/rpython/memory/gctransform/test/test_framework.py b/pypy/rpython/memory/gctransform/test/test_framework.py --- a/pypy/rpython/memory/gctransform/test/test_framework.py +++ b/pypy/rpython/memory/gctransform/test/test_framework.py @@ -36,6 +36,7 @@ from pypy.translator.c.genc import CStandaloneBuilder t = rtype(entrypoint, [s_list_of_strings]) +t.config.translation.gc = "minimark" cbuild = CStandaloneBuilder(t, entrypoint, t.config, gcpolicy=FrameworkGcPolicy2) db = cbuild.generate_graphs_for_llinterp() @@ -110,6 +111,7 @@ return g() + 2 t = rtype(entrypoint, [s_list_of_strings]) +t.config.translation.gc = "minimark" cbuild = CStandaloneBuilder(t, entrypoint, t.config, gcpolicy=FrameworkGcPolicy2) db = cbuild.generate_graphs_for_llinterp() @@ -133,6 +135,7 @@ return g() + 2 t = rtype(entrypoint, [s_list_of_strings]) +t.config.translation.gc = "minimark" cbuild = CStandaloneBuilder(t, entrypoint, t.config, gcpolicy=FrameworkGcPolicy2) f = py.test.raises(Exception, cbuild.generate_graphs_for_llinterp) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix config tests
Author: Maciej Fijalkowski Branch: Changeset: r59215:6fb576a37671 Date: 2012-12-02 09:35 -0800 http://bitbucket.org/pypy/pypy/changeset/6fb576a37671/ Log:fix config tests diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py --- a/pypy/config/pypyoption.py +++ b/pypy/config/pypyoption.py @@ -134,14 +134,6 @@ default=False), ]), -BoolOption("nofaking", "disallow faking in the object space", - default=False, - requires=[ - ("objspace.usemodules.posix", True), - ("objspace.usemodules.time", True), - ("objspace.usemodules.errno", True)], - cmdline='--nofaking'), - OptionDescription("usemodules", "Which Modules should be used", [ BoolOption(modname, "use module %s" % (modname, ), default=modname in default_modules, diff --git a/pypy/config/test/test_config.py b/pypy/config/test/test_config.py --- a/pypy/config/test/test_config.py +++ b/pypy/config/test/test_config.py @@ -64,7 +64,6 @@ assert '_cfgimpl_values' in attrs # from self if sys.version_info >= (2, 6): assert 'gc' in attrs # custom attribute -assert 'objspace' in attrs# custom attribute # attrs = dir(config.gc) if sys.version_info >= (2, 6): @@ -262,14 +261,14 @@ config = Config(descr) assert config.getpaths() == ['gc.name', 'gc.dummy', 'gc.float', 'bool', - 'objspace', 'wantref', 'str', 'wantframework', + 'wantref', 'str', 'wantframework', 'int'] assert config.getpaths() == descr.getpaths() assert config.gc.getpaths() == ['name', 'dummy', 'float'] assert config.gc.getpaths() == descr.gc.getpaths() assert config.getpaths(include_groups=True) == [ 'gc', 'gc.name', 'gc.dummy', 'gc.float', -'bool', 'objspace', 'wantref', 'str', 'wantframework', 'int'] +'bool', 'wantref', 'str', 'wantframework', 'int'] assert config.getpaths(True) == descr.getpaths(True) def test_underscore_in_option_name(): diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py --- a/pypy/interpreter/baseobjspace.py +++ b/pypy/interpreter/baseobjspace.py @@ -450,11 +450,6 @@ if 'rctime' in modules and 'time' in modules: modules.remove('time') -if not self.config.objspace.nofaking: -for modname in self.ALL_BUILTIN_MODULES: -if not LIB_PYPY.join(modname+'.py').check(file=True): -modules.append('faked+'+modname) - self._builtinmodule_list = modules return self._builtinmodule_list diff --git a/pypy/jit/tl/pypyjit.py b/pypy/jit/tl/pypyjit.py --- a/pypy/jit/tl/pypyjit.py +++ b/pypy/jit/tl/pypyjit.py @@ -32,7 +32,6 @@ config = get_pypy_config(translating=True) config.translation.backendopt.inline_threshold = 0.1 config.translation.gc = 'boehm' -config.objspace.nofaking = True config.translating = True set_opt_level(config, level='jit') config.objspace.allworkingmodules = False diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py --- a/pypy/objspace/std/objspace.py +++ b/pypy/objspace/std/objspace.py @@ -127,13 +127,6 @@ ec._py_repr = None return ec -def createframe(self, code, w_globals, outer_func=None): -from pypy.objspace.std.fake import CPythonFakeCode, CPythonFakeFrame -if not we_are_translated() and isinstance(code, CPythonFakeCode): -return CPythonFakeFrame(self, code, w_globals) -else: -return ObjSpace.createframe(self, code, w_globals, outer_func) - def gettypefor(self, cls): return self.gettypeobject(cls.typedef) @@ -236,10 +229,6 @@ # '__builtin__.Ellipsis' avoids confusion with special.Ellipsis return self.w_Ellipsis -if self.config.objspace.nofaking: -raise OperationError(self.w_RuntimeError, - self.wrap("nofaking enabled: refusing " - "to wrap cpython value %r" %(x,))) if isinstance(x, type(Exception)) and issubclass(x, Exception): w_result = self.wrap_exception_cls(x) if w_result is not None: diff --git a/pypy/objspace/std/test/test_complexobject.py b/pypy/objspace/std/test/test_complexobject.py --- a/pypy/objspace/std/test/test_complexobject.py +++ b/pypy/objspace/std/test/test_complexobject.py @@ -9,7 +9,6 @@ EPS = 1e-9 class TestW_ComplexObject: - def test_instantiation(self): def _t_complex(r=0.0,i=0.0): c = W_ComplexObject(r, i) @@ -84,6 +83,8 @@ class AppTestAppComplexTest: +spaceconfig = dict(usemodules=['binascii', 'rctime']) + def w_check_div(self, x, y): """Compute complex z=x*y, and check that z/x==y and z/y==x.""
[pypy-commit] pypy default: fix test_whatsnew
Author: Maciej Fijalkowski Branch: Changeset: r59216:219e12e2deca Date: 2012-12-02 09:42 -0800 http://bitbucket.org/pypy/pypy/changeset/219e12e2deca/ Log:fix test_whatsnew diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -1,12 +1,16 @@ == -What's new in PyPy xxx +What's new in PyPy 2.0 == .. this is a revision shortly after release-2.0-beta1 .. startrev: 0e6161a009c6 +.. branch: length-hint +Implement __lenght_hint__ according to PEP 424 + +.. branches we don't care about .. branch: autoreds -XXX -.. branch: length-hint -XXX +.. branch: release-2.0-beta1 + +.. branch: remove-PYPY_NOT_MAIN_FILE ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Issue1333: Use the macosx-version-min gcc flags.
Author: Armin Rigo Branch: Changeset: r59217:21fd46def733 Date: 2012-11-23 13:13 +0100 http://bitbucket.org/pypy/pypy/changeset/21fd46def733/ Log:Issue1333: Use the macosx-version-min gcc flags. diff --git a/pypy/translator/platform/darwin.py b/pypy/translator/platform/darwin.py --- a/pypy/translator/platform/darwin.py +++ b/pypy/translator/platform/darwin.py @@ -61,8 +61,9 @@ class Darwin_i386(Darwin): name = "darwin_i386" -link_flags = ('-arch', 'i386') -cflags = ('-arch', 'i386', '-O3', '-fomit-frame-pointer') +link_flags = ('-arch', 'i386', '-mmacosx-version-min=10.4') +cflags = ('-arch', 'i386', '-O3', '-fomit-frame-pointer', + '-mmacosx-version-min=10.4') class Darwin_PowerPC(Darwin):#xxx fixme, mwp name = "darwin_powerpc" @@ -71,5 +72,6 @@ class Darwin_x86_64(Darwin): name = "darwin_x86_64" -link_flags = ('-arch', 'x86_64') -cflags = ('-arch', 'x86_64', '-O3', '-fomit-frame-pointer') +link_flags = ('-arch', 'x86_64', '-mmacosx-version-min=10.5') +cflags = ('-arch', 'x86_64', '-O3', '-fomit-frame-pointer', + '-mmacosx-version-min=10.5') ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix the jit hook test
Author: Maciej Fijalkowski Branch: Changeset: r59218:134dd821469c Date: 2012-12-02 09:51 -0800 http://bitbucket.org/pypy/pypy/changeset/134dd821469c/ Log:fix the jit hook test diff --git a/pypy/module/pypyjit/test/test_jit_hook.py b/pypy/module/pypyjit/test/test_jit_hook.py --- a/pypy/module/pypyjit/test/test_jit_hook.py +++ b/pypy/module/pypyjit/test/test_jit_hook.py @@ -120,7 +120,6 @@ assert info.loop_no == 0 assert info.type == 'loop' raises(TypeError, 'info.bridge_no') -assert info.key == ('loop', 0) assert len(info.operations) == 4 int_add = info.operations[0] dmp = info.operations[1] ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-globals-in-jit: Fix the first half of test_gc_integration.
Author: Armin Rigo Branch: remove-globals-in-jit Changeset: r59219:dec536747d8e Date: 2012-12-02 09:54 -0800 http://bitbucket.org/pypy/pypy/changeset/dec536747d8e/ Log:Fix the first half of test_gc_integration. diff --git a/pypy/jit/backend/x86/test/test_gc_integration.py b/pypy/jit/backend/x86/test/test_gc_integration.py --- a/pypy/jit/backend/x86/test/test_gc_integration.py +++ b/pypy/jit/backend/x86/test/test_gc_integration.py @@ -8,8 +8,8 @@ from pypy.jit.metainterp.resoperation import rop, ResOperation from pypy.jit.codewriter import heaptracker from pypy.jit.codewriter.effectinfo import EffectInfo -from pypy.jit.backend.llsupport.descr import GcCache, FieldDescr, FLAG_SIGNED -from pypy.jit.backend.llsupport.gc import GcLLDescription +from pypy.jit.backend.llsupport.descr import FieldDescr, FLAG_SIGNED +from pypy.jit.backend.llsupport.gc import GcLLDescription, GcLLDescr_boehm from pypy.jit.backend.detect_cpu import getcpuclass from pypy.jit.backend.x86.regalloc import RegAlloc from pypy.jit.backend.x86.arch import WORD, FRAME_FIXED_SIZE @@ -17,7 +17,6 @@ from pypy.rpython.lltypesystem import lltype, llmemory, rffi from pypy.rpython.annlowlevel import llhelper from pypy.rpython.lltypesystem import rclass, rstr -from pypy.jit.backend.llsupport.gc import GcLLDescr_framework from pypy.jit.backend.x86.test.test_regalloc import MockAssembler from pypy.jit.backend.x86.test.test_regalloc import BaseTestRegalloc @@ -40,25 +39,15 @@ assert shape[0] == 'shape' return ['compressed'] + shape[1:] -class MockGcDescr(GcCache): -get_malloc_slowpath_addr = None -write_barrier_descr = None -moving_gc = True +class MockGcDescr(GcLLDescr_boehm): gcrootmap = MockGcRootMap() -def initialize(self): -pass - -_record_constptrs = GcLLDescr_framework._record_constptrs.im_func -rewrite_assembler = GcLLDescr_framework.rewrite_assembler.im_func -getframedescrs= GcLLDescr_framework.getframedescrs.im_func - class TestRegallocDirectGcIntegration(object): def test_mark_gc_roots(self): cpu = CPU(None, None) cpu.setup_once() -regalloc = RegAlloc(MockAssembler(cpu, MockGcDescr(False))) +regalloc = RegAlloc(MockAssembler(cpu, MockGcDescr(None, None, None))) regalloc.assembler.datablockwrapper = 'fakedatablockwrapper' boxes = [BoxPtr() for i in range(len(X86RegisterManager.all_regs))] longevity = {} @@ -91,7 +80,7 @@ class TestRegallocGcIntegration(BaseTestRegalloc): cpu = CPU(None, None) -cpu.gc_ll_descr = MockGcDescr(False) +cpu.gc_ll_descr = GcLLDescr_boehm(None, None, None) cpu.setup_once() S = lltype.GcForwardReference() diff --git a/pypy/jit/backend/x86/test/test_regalloc.py b/pypy/jit/backend/x86/test/test_regalloc.py --- a/pypy/jit/backend/x86/test/test_regalloc.py +++ b/pypy/jit/backend/x86/test/test_regalloc.py @@ -193,7 +193,7 @@ for index in range(0, end)] def getptr(self, index, T): -gcref = self.cpu.get_latest_value_ref(index) +gcref = self.cpu.get_latest_value_ref(self.deadframe, index) return lltype.cast_opaque_ptr(T, gcref) def attach_bridge(self, ops, loop, guard_op_index, **kwds): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-globals-in-jit: Fix the second half of test_gc_integration.
Author: Armin Rigo Branch: remove-globals-in-jit Changeset: r59220:fd3e4effa2fe Date: 2012-12-02 10:03 -0800 http://bitbucket.org/pypy/pypy/changeset/fd3e4effa2fe/ Log:Fix the second half of test_gc_integration. diff --git a/pypy/jit/backend/x86/test/test_gc_integration.py b/pypy/jit/backend/x86/test/test_gc_integration.py --- a/pypy/jit/backend/x86/test/test_gc_integration.py +++ b/pypy/jit/backend/x86/test/test_gc_integration.py @@ -208,17 +208,17 @@ def test_malloc_fastpath(self): ops = ''' -[] +[i0] p0 = call_malloc_nursery(16) p1 = call_malloc_nursery(32) p2 = call_malloc_nursery(16) -finish(p0, p1, p2) +guard_true(i0) [p0, p1, p2] ''' -self.interpret(ops, []) +self.interpret(ops, [0]) # check the returned pointers gc_ll_descr = self.cpu.gc_ll_descr nurs_adr = rffi.cast(lltype.Signed, gc_ll_descr.nursery) -ref = self.cpu.get_latest_value_ref +ref = lambda n: self.cpu.get_latest_value_ref(self.deadframe, n) assert rffi.cast(lltype.Signed, ref(0)) == nurs_adr + 0 assert rffi.cast(lltype.Signed, ref(1)) == nurs_adr + 16 assert rffi.cast(lltype.Signed, ref(2)) == nurs_adr + 48 @@ -230,17 +230,17 @@ def test_malloc_slowpath(self): ops = ''' -[] +[i0] p0 = call_malloc_nursery(16) p1 = call_malloc_nursery(32) p2 = call_malloc_nursery(24) # overflow -finish(p0, p1, p2) +guard_true(i0) [p0, p1, p2] ''' -self.interpret(ops, []) +self.interpret(ops, [0]) # check the returned pointers gc_ll_descr = self.cpu.gc_ll_descr nurs_adr = rffi.cast(lltype.Signed, gc_ll_descr.nursery) -ref = self.cpu.get_latest_value_ref +ref = lambda n: self.cpu.get_latest_value_ref(self.deadframe, n) assert rffi.cast(lltype.Signed, ref(0)) == nurs_adr + 0 assert rffi.cast(lltype.Signed, ref(1)) == nurs_adr + 16 assert rffi.cast(lltype.Signed, ref(2)) == nurs_adr + 0 @@ -273,7 +273,7 @@ for i in range(16): self.namespace['ds%i' % i] = cpu.fielddescrof(S2, 's%d' % i) ops = ''' -[p0] +[i0, p0] p1 = getfield_gc(p0, descr=ds0) p2 = getfield_gc(p0, descr=ds1) p3 = getfield_gc(p0, descr=ds2) @@ -295,21 +295,21 @@ p17 = call_malloc_nursery(40) p18 = call_malloc_nursery(40) # overflow # -finish(p1, p2, p3, p4, p5, p6, p7, p8, \ - p9, p10, p11, p12, p13, p14, p15, p16) +guard_true(i0) [p1, p2, p3, p4, p5, p6, \ +p7, p8, p9, p10, p11, p12, p13, p14, p15, p16] ''' s2 = lltype.malloc(S2) for i in range(16): setattr(s2, 's%d' % i, lltype.malloc(S1)) s2ref = lltype.cast_opaque_ptr(llmemory.GCREF, s2) # -self.interpret(ops, [s2ref]) +self.interpret(ops, [0, s2ref]) gc_ll_descr = cpu.gc_ll_descr gc_ll_descr.check_nothing_in_nursery() assert gc_ll_descr.calls == [40] # check the returned pointers for i in range(16): -s1ref = self.cpu.get_latest_value_ref(i) +s1ref = self.cpu.get_latest_value_ref(self.deadframe, i) s1 = lltype.cast_opaque_ptr(lltype.Ptr(S1), s1ref) assert s1 == getattr(s2, 's%d' % i) @@ -421,7 +421,7 @@ for i in range(16): self.namespace['ds%i' % i] = cpu.fielddescrof(S2, 's%d' % i) ops = ''' -[p0] +[i0, p0] p1 = getfield_gc(p0, descr=ds0) p2 = getfield_gc(p0, descr=ds1) p3 = getfield_gc(p0, descr=ds2) @@ -443,8 +443,8 @@ p17 = call_malloc_nursery(40) p18 = call_malloc_nursery(40) # overflow # -finish(p1, p2, p3, p4, p5, p6, p7, p8, \ - p9, p10, p11, p12, p13, p14, p15, p16) +guard_true(i0) [p1, p2, p3, p4, p5, p6, p7, p8, \ + p9, p10, p11, p12, p13, p14, p15, p16] ''' s2 = lltype.malloc(S2) for i in range(16): @@ -453,13 +453,13 @@ gc_ll_descr.gcrootmap.should_see.append(s1) s2ref = lltype.cast_opaque_ptr(llmemory.GCREF, s2) # -self.interpret(ops, [s2ref]) +self.interpret(ops, [0, s2ref]) gc_ll_descr.check_nothing_in_nursery() assert gc_ll_descr.calls == [40] gc_ll_descr.gcrootmap.check_initial_and_final_state() # check the returned pointers for i in range(16): -s1ref = self.cpu.get_latest_value_ref(i) +s1ref = self.cpu.get_latest_value_ref(self.deadframe, i) s1 = lltype.cast_opaque_ptr(lltype.Ptr(S1), s1ref) for j in range(16): assert s1 != getattr(s2, 's%d' % j) ___ pypy-commit mailin
[pypy-commit] pypy fix-lookinside-iff-oopspec: (fijal, alex, mike) initial work
Author: Alex Gaynor Branch: fix-lookinside-iff-oopspec Changeset: r59221:e0252730e86d Date: 2012-12-02 10:33 -0800 http://bitbucket.org/pypy/pypy/changeset/e0252730e86d/ Log:(fijal, alex, mike) initial work diff --git a/pypy/jit/metainterp/test/test_list.py b/pypy/jit/metainterp/test/test_list.py --- a/pypy/jit/metainterp/test/test_list.py +++ b/pypy/jit/metainterp/test/test_list.py @@ -1,6 +1,6 @@ import py from pypy.rlib.objectmodel import newlist_hint -from pypy.rlib.jit import JitDriver +from pypy.rlib.jit import JitDriver, promote from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin @@ -272,6 +272,22 @@ r = self.interp_operations(f, [-1]) assert r == 0 +def test_list_mul_nonzero(self): +driver = JitDriver(greens=[], reds=['i', 'n']) + +def f(n): +i = 0 +while i < n: +driver.jit_merge_point(i=i, n=n) +x = promote(n) +l = [-1] * x +i -= l[2] +return i +res = self.meta_interp(f, [5]) +assert res == 5 +self.check_resops(call=0) + + class TestOOtype(ListTests, OOJitMixin): pass diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py --- a/pypy/rlib/jit.py +++ b/pypy/rlib/jit.py @@ -161,8 +161,7 @@ def trampoline(%(arguments)s): return func(%(arguments)s) if hasattr(func, "oopspec"): -# XXX: This seems like it should be here, but it causes errors. -# trampoline.oopspec = func.oopspec +trampoline.oopspec = func.oopspec del func.oopspec trampoline.__name__ = func.__name__ + "_trampoline" trampoline._annspecialcase_ = "specialize:call_location" ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-globals-in-jit: Skip these two tests when run from backend/x86/test. The issue is
Author: Armin Rigo Branch: remove-globals-in-jit Changeset: r59222:2163d5fc96d7 Date: 2012-12-02 10:38 -0800 http://bitbucket.org/pypy/pypy/changeset/2163d5fc96d7/ Log:Skip these two tests when run from backend/x86/test. The issue is obscure and has to do with hide()/show() not working with ll2ctypes. diff --git a/pypy/jit/backend/llgraph/runner.py b/pypy/jit/backend/llgraph/runner.py --- a/pypy/jit/backend/llgraph/runner.py +++ b/pypy/jit/backend/llgraph/runner.py @@ -164,6 +164,7 @@ supports_longlong = r_uint is not r_ulonglong supports_singlefloats = True translate_support_code = False +is_llgraph = True def __init__(self, rtyper, stats=None, *ignored_args, **ignored_kwds): model.AbstractCPU.__init__(self) diff --git a/pypy/jit/metainterp/test/test_recursive.py b/pypy/jit/metainterp/test/test_recursive.py --- a/pypy/jit/metainterp/test/test_recursive.py +++ b/pypy/jit/metainterp/test/test_recursive.py @@ -849,7 +849,13 @@ res = self.meta_interp(main, [0], inline=True) assert res == main(0) +def _skip_if_untranslated_on_a_real_backend(self): +if not hasattr(self.CPUClass, 'is_llgraph'): +py.test.skip("xxx only works on the llgraph backend, or " + "fully translated") + def test_directly_call_assembler_virtualizable_force1(self): +self._skip_if_untranslated_on_a_real_backend() class Thing(object): def __init__(self, val): self.val = val @@ -944,6 +950,7 @@ assert res == main(0, 10, 1) def test_directly_call_assembler_virtualizable_force_blackhole(self): +self._skip_if_untranslated_on_a_real_backend() class Thing(object): def __init__(self, val): self.val = val ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-globals-in-jit: Test fixes
Author: Armin Rigo Branch: remove-globals-in-jit Changeset: r59223:f4c0e08b7015 Date: 2012-12-02 10:58 -0800 http://bitbucket.org/pypy/pypy/changeset/f4c0e08b7015/ Log:Test fixes diff --git a/pypy/jit/backend/x86/test/test_regalloc.py b/pypy/jit/backend/x86/test/test_regalloc.py --- a/pypy/jit/backend/x86/test/test_regalloc.py +++ b/pypy/jit/backend/x86/test/test_regalloc.py @@ -267,7 +267,6 @@ ''' S = lltype.GcStruct('S') ptr = lltype.malloc(S) -self.cpu.clear_latest_values(2) self.interpret(ops, [0, ptr]) assert self.getptr(0, lltype.Ptr(S)) == ptr @@ -634,7 +633,7 @@ ops = ''' [i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i9b] i10 = call(ConstClass(f1ptr), i0, descr=f1_calldescr) -finish(i10, i1, i2, i3, i4, i5, i6, i7, i8, i9, i9b) +guard_false(i10) [i10, i1, i2, i3, i4, i5, i6, i7, i8, i9, i9b] ''' loop = self.interpret(ops, [4, 7, 9, 9 ,9, 9, 9, 9, 9, 9, 8]) assert self.getints(11) == [5, 7, 9, 9, 9, 9, 9, 9, 9, 9, 8] @@ -645,7 +644,7 @@ ops = ''' [i1, i2, i3, i4, i5, i6, i7, i8, i9, i9b, i0] i10 = call(ConstClass(f1ptr), i0, descr=f1_calldescr) -finish(i10, i1, i2, i3, i4, i5, i6, i7, i8, i9, i9b) +guard_false(i10) [i10, i1, i2, i3, i4, i5, i6, i7, i8, i9, i9b] ''' loop = self.interpret(ops, [7, 9, 9 ,9, 9, 9, 9, 9, 9, 8, 4]) assert self.getints(11) == [5, 7, 9, 9, 9, 9, 9, 9, 9, 9, 8] @@ -657,7 +656,7 @@ [i0, i1, i2, i3, i4, i5, i6, i7, i8, i9] i10 = call(ConstClass(f1ptr), i0, descr=f1_calldescr) i11 = call(ConstClass(f2ptr), i10, i1, descr=f2_calldescr) -finish(i11, i1, i2, i3, i4, i5, i6, i7, i8, i9) +guard_false(i5) [i11, i1, i2, i3, i4, i5, i6, i7, i8, i9] ''' loop = self.interpret(ops, [4, 7, 9, 9 ,9, 9, 9, 9, 9, 9]) assert self.getints(10) == [5*7, 7, 9, 9, 9, 9, 9, 9, 9, 9] @@ -683,7 +682,7 @@ [i0, i1] i2 = call(ConstClass(f1ptr), i0, descr=f1_calldescr) guard_value(i2, 0, descr=fdescr1) [i2, i0, i1] -finish(i1) +guard_false(i1) [i1] ''' loop = self.interpret(ops, [4, 7]) assert self.getint(0) == 5 @@ -694,7 +693,7 @@ ops = ''' [i2, i0, i1] i3 = call(ConstClass(f2ptr), i2, i1, descr=f2_calldescr) -finish(i3, i0, descr=fdescr2) +guard_false(i0, descr=fdescr2) [i3, i0] ''' bridge = self.attach_bridge(ops, loop, -2) @@ -710,7 +709,7 @@ [i0, i1] i2 = call(ConstClass(f2ptr), i0, i1, descr=f2_calldescr) guard_value(i2, 0, descr=fdescr1) [i2] -finish(i2) +guard_false(i2) [i2] ''' loop = self.interpret(ops, [4, 7]) assert self.getint(0) == 4*7 @@ -721,7 +720,7 @@ ops = ''' [i2] i3 = call(ConstClass(f1ptr), i2, descr=f1_calldescr) -finish(i3, descr=fdescr2) +guard_false(i3, descr=fdescr2) [i3] ''' bridge = self.attach_bridge(ops, loop, -2) diff --git a/pypy/jit/backend/x86/test/test_regalloc2.py b/pypy/jit/backend/x86/test/test_regalloc2.py --- a/pypy/jit/backend/x86/test/test_regalloc2.py +++ b/pypy/jit/backend/x86/test/test_regalloc2.py @@ -22,9 +22,9 @@ cpu.setup_once() looptoken = JitCellToken() cpu.compile_loop(inputargs, operations, looptoken) -cpu.execute_token(looptoken, 9) -assert cpu.get_latest_value_int(0) == (9 >> 3) -assert cpu.get_latest_value_int(1) == (~18) +deadframe = cpu.execute_token(looptoken, 9) +assert cpu.get_latest_value_int(deadframe, 0) == (9 >> 3) +assert cpu.get_latest_value_int(deadframe, 1) == (~18) def test_bug_int_is_true_1(): v1 = BoxInt() @@ -44,10 +44,10 @@ cpu.setup_once() looptoken = JitCellToken() cpu.compile_loop(inputargs, operations, looptoken) -cpu.execute_token(looptoken, -10) -assert cpu.get_latest_value_int(0) == 0 -assert cpu.get_latest_value_int(1) == -1000 -assert cpu.get_latest_value_int(2) == 1 +deadframe = cpu.execute_token(looptoken, -10) +assert cpu.get_latest_value_int(deadframe, 0) == 0 +assert cpu.get_latest_value_int(deadframe, 1) == -1000 +assert cpu.get_latest_value_int(deadframe, 2) == 1 def test_bug_0(): v1 = BoxInt() @@ -140,21 +140,22 @@ cpu.setup_once() looptoken = JitCellToken() cpu.compile_loop(inputargs, operations, looptoken) -cpu.execute_token(looptoken, -13, 10, 10, 8, -8, -16, -18, 46, -12, 26) -assert cpu.get_latest_value_int(0) == 0 -assert cpu.get_latest_value_int(1) == 0 -assert cpu.get_latest_value_int(2) == 0 -assert cpu.get_latest_value_int(3) == 0 -assert cpu.get_latest_value_int(4) == 1 -assert cpu.get_latest_value_int(5) == -7 -assert cpu.get_latest_value_int(6) == 1 -assert cpu.get_latest_value_int(7) == 0 -
[pypy-commit] pypy remove-globals-in-jit: More tests to skip when running untranslated in a real backend...
Author: Armin Rigo Branch: remove-globals-in-jit Changeset: r59224:a2e6e969bafd Date: 2012-12-02 11:05 -0800 http://bitbucket.org/pypy/pypy/changeset/a2e6e969bafd/ Log:More tests to skip when running untranslated in a real backend... diff --git a/pypy/jit/metainterp/test/test_virtualizable.py b/pypy/jit/metainterp/test/test_virtualizable.py --- a/pypy/jit/metainterp/test/test_virtualizable.py +++ b/pypy/jit/metainterp/test/test_virtualizable.py @@ -660,7 +660,13 @@ self.check_aborted_count(3) self.check_jitcell_token_count(0) +def _skip_if_untranslated_on_a_real_backend(self): +if not hasattr(self.CPUClass, 'is_llgraph'): +py.test.skip("xxx only works on the llgraph backend, or " + "fully translated") + def test_external_read_sometimes(self): +self._skip_if_untranslated_on_a_real_backend() jitdriver = JitDriver(greens = [], reds = ['frame'], virtualizables = ['frame']) @@ -697,6 +703,7 @@ assert res == f(123) def test_external_read_sometimes_with_virtuals(self): +self._skip_if_untranslated_on_a_real_backend() jitdriver = JitDriver(greens = [], reds = ['frame'], virtualizables = ['frame']) @@ -740,6 +747,7 @@ assert res == f(123) def test_external_read_sometimes_changing_virtuals(self): +self._skip_if_untranslated_on_a_real_backend() jitdriver = JitDriver(greens = [], reds = ['frame'], virtualizables = ['frame']) @@ -788,6 +796,7 @@ assert res == f(123) def test_external_read_sometimes_with_exception(self): +self._skip_if_untranslated_on_a_real_backend() jitdriver = JitDriver(greens = [], reds = ['frame'], virtualizables = ['frame']) @@ -830,6 +839,7 @@ assert res == f(123) def test_external_read_sometimes_dont_compile_guard(self): +self._skip_if_untranslated_on_a_real_backend() jitdriver = JitDriver(greens = [], reds = ['frame'], virtualizables = ['frame']) @@ -866,6 +876,7 @@ assert res == f(123) def test_external_read_sometimes_recursive(self): +self._skip_if_untranslated_on_a_real_backend() jitdriver = JitDriver(greens = [], reds = ['rec', 'frame'], virtualizables = ['frame']) @@ -917,6 +928,7 @@ assert res == main(123) def test_external_write_sometimes(self): +self._skip_if_untranslated_on_a_real_backend() jitdriver = JitDriver(greens = [], reds = ['frame'], virtualizables = ['frame']) diff --git a/pypy/jit/metainterp/test/test_virtualref.py b/pypy/jit/metainterp/test/test_virtualref.py --- a/pypy/jit/metainterp/test/test_virtualref.py +++ b/pypy/jit/metainterp/test/test_virtualref.py @@ -285,7 +285,13 @@ new_array=6) # next1/2/3 self.check_aborted_count(0) +def _skip_if_untranslated_on_a_real_backend(self): +if not hasattr(self.CPUClass, 'is_llgraph'): +py.test.skip("xxx only works on the llgraph backend, or " + "fully translated") + def test_simple_force_sometimes(self): +self._skip_if_untranslated_on_a_real_backend() myjitdriver = JitDriver(greens = [], reds = ['n']) # A = lltype.GcArray(lltype.Signed) @@ -511,6 +517,7 @@ self.check_aborted_count(0) def test_alloc_virtualref_and_then_alloc_structure(self): +self._skip_if_untranslated_on_a_real_backend() myjitdriver = JitDriver(greens = [], reds = ['n']) # class XY: @@ -569,6 +576,7 @@ py.test.raises(UnknownException, "self.meta_interp(fn, [10])") def test_call_virtualref_already_forced(self): +self._skip_if_untranslated_on_a_real_backend() myjitdriver = JitDriver(greens = [], reds = ['n', 'res']) # class XY: ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy fix-lookinside-iff-oopspec: fix tests and oopspecs + look_inside_iff
Author: Alex Gaynor Branch: fix-lookinside-iff-oopspec Changeset: r59225:3e3d959713c8 Date: 2012-12-02 11:20 -0800 http://bitbucket.org/pypy/pypy/changeset/3e3d959713c8/ Log:fix tests and oopspecs + look_inside_iff diff --git a/pypy/jit/metainterp/test/support.py b/pypy/jit/metainterp/test/support.py --- a/pypy/jit/metainterp/test/support.py +++ b/pypy/jit/metainterp/test/support.py @@ -10,6 +10,8 @@ from pypy.jit.codewriter.policy import JitPolicy from pypy.jit.codewriter import codewriter, longlong from pypy.rlib.rfloat import isnan +from pypy.translator.backendopt.all import backend_optimizations + def _get_jitcodes(testself, CPUClass, func, values, type_system, supports_longlong=False, translationoptions={}, **kwds): @@ -68,7 +70,9 @@ policy = JitPolicy() policy.set_supports_floats(True) policy.set_supports_longlong(supports_longlong) -cw.find_all_graphs(policy) +graphs = cw.find_all_graphs(policy) +if kwds.get("backendopt"): +backend_optimizations(rtyper.annotator.translator, graphs=graphs) # testself.warmrunnerstate = FakeWarmRunnerState() testself.warmrunnerstate.cpu = cpu diff --git a/pypy/jit/metainterp/test/test_list.py b/pypy/jit/metainterp/test/test_list.py --- a/pypy/jit/metainterp/test/test_list.py +++ b/pypy/jit/metainterp/test/test_list.py @@ -79,7 +79,7 @@ self.check_loops(setarrayitem_gc=0, call=0) def test_vlist_with_default_read(self): -jitdriver = JitDriver(greens = [], reds = ['n']) +jitdriver = JitDriver(greens=[], reds=['n']) def f(n): l = [1] * 20 while n > 0: @@ -93,7 +93,7 @@ n -= 1 return l[0] -res = self.meta_interp(f, [10], listops=True) +res = self.meta_interp(f, [10], listops=True, backendopt=True) assert res == f(10) self.check_resops(setarrayitem_gc=0, call=0, getarrayitem_gc=0) diff --git a/pypy/jit/metainterp/test/test_tracingopts.py b/pypy/jit/metainterp/test/test_tracingopts.py --- a/pypy/jit/metainterp/test/test_tracingopts.py +++ b/pypy/jit/metainterp/test/test_tracingopts.py @@ -339,7 +339,7 @@ res = self.interp_operations(fn, [7]) assert res == 7 + 7 + 1 self.check_operations_history(setarrayitem_gc=2, -setfield_gc=2) +setfield_gc=0) def test_virtualizable_with_array_heap_cache(self): myjitdriver = jit.JitDriver(greens = [], reds = ['n', 'x', 'i', 'frame'], @@ -559,7 +559,7 @@ a1 = [0] * n g.a = a1 return len(a1) + res -res = self.interp_operations(fn, [7]) +res = self.interp_operations(fn, [7], backendopt=True) assert res == 7 * 3 self.check_operations_history(arraylen_gc=1) @@ -574,7 +574,7 @@ x = [0] * n x[2] = 21 return len(a[:n]) + x[2] -res = self.interp_operations(fn, [3]) +res = self.interp_operations(fn, [3], backendopt=True) assert res == 24 self.check_operations_history(getarrayitem_gc=0) diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py --- a/pypy/rlib/jit.py +++ b/pypy/rlib/jit.py @@ -172,6 +172,7 @@ else: return trampoline(%(arguments)s) f.__name__ = func.__name__ + "_look_inside_iff" +f._always_inline = True """ % {"arguments": ", ".join(args)}).compile() in d return d["f"] return inner ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy fix-lookinside-iff-oopspec: Closing to be merged branch
Author: Alex Gaynor Branch: fix-lookinside-iff-oopspec Changeset: r59226:307c9ab5e989 Date: 2012-12-02 11:20 -0800 http://bitbucket.org/pypy/pypy/changeset/307c9ab5e989/ Log:Closing to be merged branch ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: (alex, mike, fijal, arigo): fix interaction of JIT look inside iff and oopspecs
Author: Alex Gaynor Branch: Changeset: r59227:61758d80f0a1 Date: 2012-12-02 11:21 -0800 http://bitbucket.org/pypy/pypy/changeset/61758d80f0a1/ Log:(alex, mike, fijal, arigo): fix interaction of JIT look inside iff and oopspecs diff --git a/pypy/jit/metainterp/test/support.py b/pypy/jit/metainterp/test/support.py --- a/pypy/jit/metainterp/test/support.py +++ b/pypy/jit/metainterp/test/support.py @@ -10,6 +10,8 @@ from pypy.jit.codewriter.policy import JitPolicy from pypy.jit.codewriter import codewriter, longlong from pypy.rlib.rfloat import isnan +from pypy.translator.backendopt.all import backend_optimizations + def _get_jitcodes(testself, CPUClass, func, values, type_system, supports_longlong=False, translationoptions={}, **kwds): @@ -68,7 +70,9 @@ policy = JitPolicy() policy.set_supports_floats(True) policy.set_supports_longlong(supports_longlong) -cw.find_all_graphs(policy) +graphs = cw.find_all_graphs(policy) +if kwds.get("backendopt"): +backend_optimizations(rtyper.annotator.translator, graphs=graphs) # testself.warmrunnerstate = FakeWarmRunnerState() testself.warmrunnerstate.cpu = cpu diff --git a/pypy/jit/metainterp/test/test_list.py b/pypy/jit/metainterp/test/test_list.py --- a/pypy/jit/metainterp/test/test_list.py +++ b/pypy/jit/metainterp/test/test_list.py @@ -1,6 +1,6 @@ import py from pypy.rlib.objectmodel import newlist_hint -from pypy.rlib.jit import JitDriver +from pypy.rlib.jit import JitDriver, promote from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin @@ -79,7 +79,7 @@ self.check_loops(setarrayitem_gc=0, call=0) def test_vlist_with_default_read(self): -jitdriver = JitDriver(greens = [], reds = ['n']) +jitdriver = JitDriver(greens=[], reds=['n']) def f(n): l = [1] * 20 while n > 0: @@ -93,7 +93,7 @@ n -= 1 return l[0] -res = self.meta_interp(f, [10], listops=True) +res = self.meta_interp(f, [10], listops=True, backendopt=True) assert res == f(10) self.check_resops(setarrayitem_gc=0, call=0, getarrayitem_gc=0) @@ -272,6 +272,22 @@ r = self.interp_operations(f, [-1]) assert r == 0 +def test_list_mul_nonzero(self): +driver = JitDriver(greens=[], reds=['i', 'n']) + +def f(n): +i = 0 +while i < n: +driver.jit_merge_point(i=i, n=n) +x = promote(n) +l = [-1] * x +i -= l[2] +return i +res = self.meta_interp(f, [5]) +assert res == 5 +self.check_resops(call=0) + + class TestOOtype(ListTests, OOJitMixin): pass diff --git a/pypy/jit/metainterp/test/test_tracingopts.py b/pypy/jit/metainterp/test/test_tracingopts.py --- a/pypy/jit/metainterp/test/test_tracingopts.py +++ b/pypy/jit/metainterp/test/test_tracingopts.py @@ -339,7 +339,7 @@ res = self.interp_operations(fn, [7]) assert res == 7 + 7 + 1 self.check_operations_history(setarrayitem_gc=2, -setfield_gc=2) +setfield_gc=0) def test_virtualizable_with_array_heap_cache(self): myjitdriver = jit.JitDriver(greens = [], reds = ['n', 'x', 'i', 'frame'], @@ -559,7 +559,7 @@ a1 = [0] * n g.a = a1 return len(a1) + res -res = self.interp_operations(fn, [7]) +res = self.interp_operations(fn, [7], backendopt=True) assert res == 7 * 3 self.check_operations_history(arraylen_gc=1) @@ -574,7 +574,7 @@ x = [0] * n x[2] = 21 return len(a[:n]) + x[2] -res = self.interp_operations(fn, [3]) +res = self.interp_operations(fn, [3], backendopt=True) assert res == 24 self.check_operations_history(getarrayitem_gc=0) diff --git a/pypy/rlib/jit.py b/pypy/rlib/jit.py --- a/pypy/rlib/jit.py +++ b/pypy/rlib/jit.py @@ -161,8 +161,7 @@ def trampoline(%(arguments)s): return func(%(arguments)s) if hasattr(func, "oopspec"): -# XXX: This seems like it should be here, but it causes errors. -# trampoline.oopspec = func.oopspec +trampoline.oopspec = func.oopspec del func.oopspec trampoline.__name__ = func.__name__ + "_trampoline" trampoline._annspecialcase_ = "specialize:call_location" @@ -173,6 +172,7 @@ else: return trampoline(%(arguments)s) f.__name__ = func.__name__ + "_look_inside_iff" +f._always_inline = True """ % {"arguments": ", ".join(args)}).compile() in d return d["f"] return inner ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-comm
[pypy-commit] pypy default: Made the invalidation of boxes more intelligent at calls in the heapcache.
Author: Alex Gaynor Branch: Changeset: r59228:97f0ffc6c659 Date: 2012-12-02 11:50 -0800 http://bitbucket.org/pypy/pypy/changeset/97f0ffc6c659/ Log:Made the invalidation of boxes more intelligent at calls in the heapcache. diff --git a/pypy/jit/metainterp/heapcache.py b/pypy/jit/metainterp/heapcache.py --- a/pypy/jit/metainterp/heapcache.py +++ b/pypy/jit/metainterp/heapcache.py @@ -128,6 +128,18 @@ if frombox not in self.new_boxes: del cache[frombox] return +else: +# Only invalidate things that are either escaped or arguments +for descr, boxes in self.heap_cache.iteritems(): +for box in boxes.keys(): +if not self.is_unescaped(box) or box in argboxes: +del boxes[box] +for descr, indices in self.heap_array_cache.iteritems(): +for boxes in indices.itervalues(): +for box in boxes.keys(): +if not self.is_unescaped(box) or box in argboxes: +del boxes[box] +return self.heap_cache.clear() self.heap_array_cache.clear() diff --git a/pypy/jit/metainterp/test/test_heapcache.py b/pypy/jit/metainterp/test/test_heapcache.py --- a/pypy/jit/metainterp/test/test_heapcache.py +++ b/pypy/jit/metainterp/test/test_heapcache.py @@ -18,7 +18,7 @@ index2 = ConstInt(1) -class FakeEffektinfo(object): +class FakeEffectinfo(object): EF_ELIDABLE_CANNOT_RAISE = 0 #elidable function (and cannot raise) EF_LOOPINVARIANT = 1 #special: call it only once per loop EF_CANNOT_RAISE= 2 #a function which cannot raise @@ -39,7 +39,7 @@ self.oopspecindex = oopspecindex def get_extra_info(self): -return FakeEffektinfo(self.extraeffect, self.oopspecindex) +return FakeEffectinfo(self.extraeffect, self.oopspecindex) class TestHeapCache(object): def test_known_class_box(self): @@ -252,7 +252,7 @@ assert h.getarrayitem(box1, index2, descr1) is box4 h.invalidate_caches( -rop.CALL, FakeCallDescr(FakeEffektinfo.EF_ELIDABLE_CANNOT_RAISE), []) +rop.CALL, FakeCallDescr(FakeEffectinfo.EF_ELIDABLE_CANNOT_RAISE), []) assert h.getfield(box1, descr1) is box2 assert h.getarrayitem(box1, index1, descr1) is box2 assert h.getarrayitem(box1, index2, descr1) is box4 @@ -263,10 +263,10 @@ assert h.getarrayitem(box1, index2, descr1) is box4 h.invalidate_caches( -rop.CALL_LOOPINVARIANT, FakeCallDescr(FakeEffektinfo.EF_LOOPINVARIANT), []) +rop.CALL_LOOPINVARIANT, FakeCallDescr(FakeEffectinfo.EF_LOOPINVARIANT), []) h.invalidate_caches( -rop.CALL, FakeCallDescr(FakeEffektinfo.EF_RANDOM_EFFECTS), []) +rop.CALL, FakeCallDescr(FakeEffectinfo.EF_RANDOM_EFFECTS), []) assert h.getfield(box1, descr1) is None assert h.getarrayitem(box1, index1, descr1) is None assert h.getarrayitem(box1, index2, descr1) is None @@ -364,13 +364,13 @@ # Just need the destination box for this call h.invalidate_caches( rop.CALL, -FakeCallDescr(FakeEffektinfo.EF_CANNOT_RAISE, FakeEffektinfo.OS_ARRAYCOPY), +FakeCallDescr(FakeEffectinfo.EF_CANNOT_RAISE, FakeEffectinfo.OS_ARRAYCOPY), [None, None, box2, None, None] ) assert h.getarrayitem(box1, index1, descr1) is box2 h.invalidate_caches( rop.CALL, -FakeCallDescr(FakeEffektinfo.EF_CANNOT_RAISE, FakeEffektinfo.OS_ARRAYCOPY), +FakeCallDescr(FakeEffectinfo.EF_CANNOT_RAISE, FakeEffectinfo.OS_ARRAYCOPY), [None, None, box3, None, None] ) assert h.getarrayitem(box1, index1, descr1) is None @@ -379,7 +379,7 @@ assert h.getarrayitem(box4, index1, descr1) is box2 h.invalidate_caches( rop.CALL, -FakeCallDescr(FakeEffektinfo.EF_CANNOT_RAISE, FakeEffektinfo.OS_ARRAYCOPY), +FakeCallDescr(FakeEffectinfo.EF_CANNOT_RAISE, FakeEffectinfo.OS_ARRAYCOPY), [None, None, box2, None, None] ) assert h.getarrayitem(box4, index1, descr1) is None @@ -451,7 +451,29 @@ assert h.is_unescaped(box1) assert h.is_unescaped(box2) h.invalidate_caches( -rop.CALL, FakeCallDescr(FakeEffektinfo.EF_RANDOM_EFFECTS), [box1] +rop.CALL, FakeCallDescr(FakeEffectinfo.EF_RANDOM_EFFECTS), [box1] ) assert not h.is_unescaped(box1) assert not h.is_unescaped(box2) + +def test_call_doesnt_invalidate_unescaped_boxes(self): +h = HeapCache() +h.new(box1) +assert h.is_unescaped(box1) +h.setfield(box1,
[pypy-commit] pypy kill-faking: Resolved merge conflicts
Author: Alex Gaynor Branch: kill-faking Changeset: r59229:395e7928acb6 Date: 2012-12-02 12:18 -0800 http://bitbucket.org/pypy/pypy/changeset/395e7928acb6/ Log:Resolved merge conflicts diff --git a/lib-python/2.7/json/decoder.py b/lib-python/2.7/json/decoder.py --- a/lib-python/2.7/json/decoder.py +++ b/lib-python/2.7/json/decoder.py @@ -62,8 +62,7 @@ DEFAULT_ENCODING = "utf-8" -def py_scanstring(s, end, encoding=None, strict=True, -_b=BACKSLASH, _m=STRINGCHUNK.match): +def py_scanstring(s, end, encoding=None, strict=True): """Scan the string s for a JSON string. End is the index of the character in s after the quote that started the JSON string. Unescapes all valid JSON string escape sequences and raises ValueError @@ -78,7 +77,7 @@ _append = chunks.append begin = end - 1 while 1: -chunk = _m(s, end) +chunk = STRINGCHUNK.match(s, end) if chunk is None: raise ValueError( errmsg("Unterminated string starting at", s, begin)) @@ -109,7 +108,7 @@ # If not a unicode escape sequence, must be in the lookup table if esc != 'u': try: -char = _b[esc] +char = BACKSLASH[esc] except KeyError: msg = "Invalid \\escape: " + repr(esc) raise ValueError(errmsg(msg, s, end)) @@ -147,7 +146,7 @@ WHITESPACE_STR = ' \t\n\r' def JSONObject(s_and_end, encoding, strict, scan_once, object_hook, - object_pairs_hook, _w=WHITESPACE.match, _ws=WHITESPACE_STR): + object_pairs_hook): s, end = s_and_end pairs = [] pairs_append = pairs.append @@ -156,8 +155,8 @@ nextchar = s[end:end + 1] # Normally we expect nextchar == '"' if nextchar != '"': -if nextchar in _ws: -end = _w(s, end).end() +if nextchar in WHITESPACE_STR: +end = WHITESPACE.match(s, end).end() nextchar = s[end:end + 1] # Trivial empty object if nextchar == '}': @@ -177,17 +176,17 @@ # To skip some function call overhead we optimize the fast paths where # the JSON key separator is ": " or just ":". if s[end:end + 1] != ':': -end = _w(s, end).end() +end = WHITESPACE.match(s, end).end() if s[end:end + 1] != ':': raise ValueError(errmsg("Expecting : delimiter", s, end)) end += 1 try: -if s[end] in _ws: +if s[end] in WHITESPACE_STR: end += 1 -if s[end] in _ws: -end = _w(s, end + 1).end() +if s[end] in WHITESPACE_STR: +end = WHITESPACE.match(s, end + 1).end() except IndexError: pass @@ -199,8 +198,8 @@ try: nextchar = s[end] -if nextchar in _ws: -end = _w(s, end + 1).end() +if nextchar in WHITESPACE_STR: +end = WHITESPACE.match(s, end + 1).end() nextchar = s[end] except IndexError: nextchar = '' @@ -213,11 +212,11 @@ try: nextchar = s[end] -if nextchar in _ws: +if nextchar in WHITESPACE_STR: end += 1 nextchar = s[end] -if nextchar in _ws: -end = _w(s, end + 1).end() +if nextchar in WHITESPACE_STR: +end = WHITESPACE.match(s, end + 1).end() nextchar = s[end] except IndexError: nextchar = '' @@ -234,12 +233,12 @@ pairs = object_hook(pairs) return pairs, end -def JSONArray(s_and_end, scan_once, _w=WHITESPACE.match, _ws=WHITESPACE_STR): +def JSONArray(s_and_end, scan_once): s, end = s_and_end values = [] nextchar = s[end:end + 1] -if nextchar in _ws: -end = _w(s, end + 1).end() +if nextchar in WHITESPACE_STR: +end = WHITESPACE.match(s, end + 1).end() nextchar = s[end:end + 1] # Look-ahead for trivial empty array if nextchar == ']': @@ -252,8 +251,8 @@ raise ValueError(errmsg("Expecting object", s, end)) _append(value) nextchar = s[end:end + 1] -if nextchar in _ws: -end = _w(s, end + 1).end() +if nextchar in WHITESPACE_STR: +end = WHITESPACE.match(s, end + 1).end() nextchar = s[end:end + 1] end += 1 if nextchar == ']': @@ -262,10 +261,10 @@ raise ValueError(errmsg("Expecting , delimiter", s, end)) try: -if s[end] in _ws: +if s[end] in WHITESPACE_STR: end += 1 -if s[end] in _ws: -end = _w(s, end + 1).end() +if s[end] in WHITESPACE_STR: +end = WHITESPACE.match(s, end + 1).end() except Index
[pypy-commit] pypy kill-faking: make another test pass
Author: Alex Gaynor Branch: kill-faking Changeset: r59234:c72eb6559f4c Date: 2012-12-02 13:34 -0800 http://bitbucket.org/pypy/pypy/changeset/c72eb6559f4c/ Log:make another test pass diff --git a/pypy/module/zipimport/test/test_undocumented.py b/pypy/module/zipimport/test/test_undocumented.py --- a/pypy/module/zipimport/test/test_undocumented.py +++ b/pypy/module/zipimport/test/test_undocumented.py @@ -16,12 +16,15 @@ os.path.join('_pkg', '_subpkg', 'submodule') ]) + class AppTestZipImport: -spaceconfig = dict(usemodules=['zipimport', 'rctime', 'struct', - 'itertools']) +spaceconfig = { +"usemodules": ['zipimport', 'rctime', 'struct', 'itertools', 'binascii'] +} + def setup_class(cls): cls.w_created_paths = cls.space.wrap(created_paths) - + def w_temp_zipfile(self, created_paths, source=True, bytecode=True): """Create a temporary zip file for testing. ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: (alex, fijal): fix interpreter tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59230:6341bd9f1673 Date: 2012-12-02 12:26 -0800 http://bitbucket.org/pypy/pypy/changeset/6341bd9f1673/ Log:(alex, fijal): fix interpreter tests diff --git a/pypy/interpreter/test/test_main.py b/pypy/interpreter/test/test_main.py --- a/pypy/interpreter/test/test_main.py +++ b/pypy/interpreter/test/test_main.py @@ -24,17 +24,18 @@ testresultoutput = '11\n' -def checkoutput(space, expected_output,f,*args): + +def checkoutput(space, expected_output, f, *args): w_oldout = space.sys.get('stdout') capturefn = udir.join('capturefile') -capturefile = capturefn.open('w') +w_capturefile = space.call_method(space.builtin, "open", space.wrap(str(capturefn)), space.wrap("w")) w_sys = space.sys.getmodule('sys') -space.setattr(w_sys, space.wrap("stdout"), space.wrap(capturefile)) +space.setattr(w_sys, space.wrap("stdout"), w_capturefile) try: f(*(args + (space,))) finally: space.setattr(w_sys, space.wrap("stdout"), w_oldout) -capturefile.close() +space.call_method(w_capturefile, "close") assert capturefn.read(mode='rU') == expected_output testfn = udir.join('tmp_hello_world.py') diff --git a/pypy/interpreter/test/test_objspace.py b/pypy/interpreter/test/test_objspace.py --- a/pypy/interpreter/test/test_objspace.py +++ b/pypy/interpreter/test/test_objspace.py @@ -320,40 +320,20 @@ class TestModuleMinimal: def test_sys_exists(self): -assert self.space.sys +assert self.space.sys def test_import_exists(self): space = self.space -assert space.builtin +assert space.builtin w_name = space.wrap('__import__') w_builtin = space.sys.getmodule('__builtin__') -w_import = self.space.getattr(w_builtin, w_name) +w_import = self.space.getattr(w_builtin, w_name) assert space.is_true(w_import) def test_sys_import(self): from pypy.interpreter.main import run_string run_string('import sys', space=self.space) -def test_get_builtinmodule_to_install(self): -space = self.space -try: -# force rebuilding with this fake builtin -space.ALL_BUILTIN_MODULES.append('this_doesnt_exist') -del space._builtinmodule_list -mods = space.get_builtinmodule_to_install() - -assert '__pypy__' in mods# real builtin -assert '_functools' not in mods # in lib_pypy -assert 'faked+_functools' not in mods # in lib_pypy -assert 'this_doesnt_exist' not in mods # not in lib_pypy -assert 'faked+this_doesnt_exist' in mods # not in lib_pypy, but in - # ALL_BUILTIN_MODULES -finally: -# rebuild the original list -space.ALL_BUILTIN_MODULES.pop() -del space._builtinmodule_list -mods = space.get_builtinmodule_to_install() - def test_dont_reload_builtin_mods_on_startup(self): from pypy.tool.option import make_config, make_objspace config = make_config(None) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: get bz2 going
Author: Alex Gaynor Branch: kill-faking Changeset: r59232:d2c47e6e1b00 Date: 2012-12-02 13:01 -0800 http://bitbucket.org/pypy/pypy/changeset/d2c47e6e1b00/ Log:get bz2 going diff --git a/pypy/module/bz2/test/test_bz2_compdecomp.py b/pypy/module/bz2/test/test_bz2_compdecomp.py --- a/pypy/module/bz2/test/test_bz2_compdecomp.py +++ b/pypy/module/bz2/test/test_bz2_compdecomp.py @@ -1,6 +1,11 @@ +import os + +import py + +from pypy.interpreter.gateway import interp2app from pypy.module.bz2.test.support import CheckAllocation from pypy.module.bz2 import interp_bz2 -import os, py + HUGE_OK = False @@ -11,9 +16,10 @@ def setup_module(mod): DATA = 'BZh91AY&SY.\xc8N\x18\x00\x01>_\x80\x00\x10@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe00\x01\x99\xaa\x00\xc0\x03F\x86\x8c#&\x83F\x9a\x03\x06\xa6\xd0\xa6\x93M\x0fQ\xa7\xa8\x06\x804hh\x12$\x11\xa4i4\xf14S\xd2\x88\xe5\xcd9gd6\x0b\n\xe9\x9b\xd5\x8a\x99\xf7\x08.K\x8ev\xfb\xf7xw\xbb\xdf\xa1\x92\xf1\xdd|/";\xa2\xba\x9f\xd5\xb1#A\xb6\xf6\xb3o\xc9\xc5y\\\xebO\xe7\x85\x9a\xbc\xb6f8\x952\xd5\xd7"%\x89>V,\xf7\xa6z\xe2\x9f\xa3\xdf\x11\x11"\xd6E)I\xa9\x13^\xca\xf3r\xd0\x03U\x922\xf26\xec\xb6\xed\x8b\xc3U\x13\x9d\xc5\x170\xa4\xfa^\x92\xacDF\x8a\x97\xd6\x19\xfe\xdd\xb8\xbd\x1a\x9a\x19\xa3\x80ankR\x8b\xe5\xd83]\xa9\xc6\x08\x82f\xf6\xb9"6l$\xb8j@\xc0\x 8a\xb0l1..\xbak\x83ls\x15\xbc\xf4\xc1\x13\xbe\xf8E\xb8\x9d\r\xa8\x9dk\x84\xd3n\xfa\xacQ\x07\xb1%y\xaav\xb4\x08\xe0z\x1b\x16\xf5\x04\xe9\xcc\xb9\x08z\x1en7.G\xfc]\xc9\x14\xe1B@\xbb!8`' -def decompress(self, data): +def decompress(space, w_data): import popen2 import bz2 +data = space.str_w(w_data) pop = popen2.Popen3("bunzip2", capturestderr=1) pop.tochild.write(data) pop.tochild.close() @@ -21,7 +27,7 @@ pop.fromchild.close() if pop.wait() != 0: res = bz2.decompress(data) -return res +return space.wrap(res) mod.TEXT = 'root:x:0:0:root:/root:/bin/bash\nbin:x:1:1:bin:/bin:\ndaemon:x:2:2:daemon:/sbin:\nadm:x:3:4:adm:/var/adm:\nlp:x:4:7:lp:/var/spool/lpd:\nsync:x:5:0:sync:/sbin:/bin/sync\nshutdown:x:6:0:shutdown:/sbin:/sbin/shutdown\nhalt:x:7:0:halt:/sbin:/sbin/halt\nmail:x:8:12:mail:/var/spool/mail:\nnews:x:9:13:news:/var/spool/news:\nuucp:x:10:14:uucp:/var/spool/uucp:\noperator:x:11:0:operator:/root:\ngames:x:12:100:games:/usr/games:\ngopher:x:13:30:gopher:/usr/lib/gopher-data:\nftp:x:14:50:FTP User:/var/ftp:/bin/bash\nnobody:x:65534:65534:Nobody:/home:\npostfix:x:100:101:postfix:/var/spool/postfix:\nniemeyer:x:500:500::/home/niemeyer:/bin/bash\npostgres:x:101:102:PostgreSQL Server:/var/lib/pgsql:/bin/bash\nmysql:x:102:103:MySQL server:/var/lib/mysql:/bin/bash\nwww:x:103:104::/var/www:/bin/false\n' mod.DATA = DATA @@ -40,9 +46,9 @@ def setup_class(cls): cls.w_TEXT = cls.space.wrap(TEXT) -cls.w_decompress = cls.space.wrap(decompress) +cls.w_decompress = cls.space.wrap(interp2app(decompress)) cls.w_HUGE_OK = cls.space.wrap(HUGE_OK) - + def test_creation(self): from bz2 import BZ2Compressor @@ -95,6 +101,7 @@ data = "%s%s" % (data, bz2c.flush()) assert self.decompress(data) == self.TEXT + class AppTestBZ2Decompressor(CheckAllocation): spaceconfig = dict(usemodules=('bz2',)) @@ -170,13 +177,14 @@ assert decompressed_data == '' raises(IOError, bz2d.decompress, self.BUGGY_DATA) + class AppTestBZ2ModuleFunctions(CheckAllocation): spaceconfig = dict(usemodules=('bz2',)) def setup_class(cls): cls.w_TEXT = cls.space.wrap(TEXT) cls.w_DATA = cls.space.wrap(DATA) -cls.w_decompress = cls.space.wrap(decompress) +cls.w_decompress = cls.space.wrap(interp2app(decompress)) cls.w_HUGE_OK = cls.space.wrap(HUGE_OK) def test_compress_function(self): diff --git a/pypy/module/bz2/test/test_bz2_file.py b/pypy/module/bz2/test/test_bz2_file.py --- a/pypy/module/bz2/test/test_bz2_file.py +++ b/pypy/module/bz2/test/test_bz2_file.py @@ -1,29 +1,34 @@ from __future__ import with_statement -import py -from pypy.module.bz2.test.support import CheckAllocation import os import random +import py + +from pypy.interpreter.gateway import unwrap_spec, interp2app + + if os.name == "nt": from py.test import skip skip("bz2 module is not available on Windows") - + def setup_module(mod): DATA = 'BZh91AY&SY.\xc8N\x18\x00\x01>_\x80\x00\x10@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe00\x01\x99\xaa\x00\xc0\x03F\x86\x8c#&\x83F\x9a\x03\x06\xa6\xd0\xa6\x93M\x0fQ\xa7\xa8\x06\x804hh\x12$\x11\xa4i4\xf14S\xd2\x88\xe5\xcd9gd6\x0b\n\xe9\x9b\xd5\x8a\x99\xf7\x08.K\x8ev\xfb\xf7xw\xbb\xdf\xa1\x92\xf1\xdd|/";\xa2\xba\x9f\xd5\xb1#A\xb6\xf6\xb3o\xc9\xc5y\\\xebO\xe7\x85\x9a\xbc\xb6f8\x952\xd5\xd7"%\x89>V,\xf7\xa6z\xe2\x9f\xa3\xdf\x11\x11"\xd6E)I\xa9\x13^\xca\xf3r\xd0\x03U\x922\xf26\xec\xb6\xed\x8b\xc3U\x13\x9d\xc5\x170\xa4\xfa^\x92\xacDF\x8a\x97\xd6\x19\xfe\x
[pypy-commit] pypy kill-faking: really fix all of interpreter
Author: Alex Gaynor Branch: kill-faking Changeset: r59231:e51355240911 Date: 2012-12-02 12:29 -0800 http://bitbucket.org/pypy/pypy/changeset/e51355240911/ Log:really fix all of interpreter diff --git a/pypy/interpreter/test/test_zzpickle_and_slow.py b/pypy/interpreter/test/test_zzpickle_and_slow.py --- a/pypy/interpreter/test/test_zzpickle_and_slow.py +++ b/pypy/interpreter/test/test_zzpickle_and_slow.py @@ -71,9 +71,12 @@ space.delitem(space.builtin.w_dict, space.wrap('restore_top_frame')) + class AppTestInterpObjectPickling: pytestmark = py.test.mark.skipif("config.option.runappdirect") -spaceconfig = dict(usemodules=['struct']) +spaceconfig = { +"usemodules": ["struct", "binascii"] +} def setup_class(cls): _attach_helpers(cls.space) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fix a bunch of tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59233:53f78807d4b1 Date: 2012-12-02 13:32 -0800 http://bitbucket.org/pypy/pypy/changeset/53f78807d4b1/ Log:fix a bunch of tests diff --git a/pypy/module/imp/test/test_app.py b/pypy/module/imp/test/test_app.py --- a/pypy/module/imp/test/test_app.py +++ b/pypy/module/imp/test/test_app.py @@ -1,8 +1,11 @@ from __future__ import with_statement MARKER = 42 + class AppTestImpModule: -spaceconfig = dict(usemodules=('imp', 'itertools')) +spaceconfig = { +"usemodules": ['imp', 'itertools', 'binascii', 'rctime'], +} def setup_class(cls): cls.w_imp = cls.space.getbuiltinmodule('imp') diff --git a/pypy/module/imp/test/test_import.py b/pypy/module/imp/test/test_import.py --- a/pypy/module/imp/test/test_import.py +++ b/pypy/module/imp/test/test_import.py @@ -139,23 +139,25 @@ def _teardown(space, w_saved_modules): space.appexec([w_saved_modules], """ -((saved_path, saved_modules)): +((saved_path, saved_modules)): import sys sys.path[:] = saved_path sys.modules.clear() sys.modules.update(saved_modules) """) + class AppTestImport: -spaceconfig = dict(usemodules=['_md5']) +spaceconfig = { +"usemodules": ['_md5', 'rctime'], +} -def setup_class(cls): # interpreter-level +def setup_class(cls): cls.w_runappdirect = cls.space.wrap(conftest.option.runappdirect) cls.saved_modules = _setup(cls.space) #XXX Compile class - -def teardown_class(cls): # interpreter-level +def teardown_class(cls): _teardown(cls.space, cls.saved_modules) def test_set_sys_modules_during_import(self): @@ -992,19 +994,22 @@ extrapath.join("urllib.py").write("print 42\n") old = os.environ.get('PYTHONPATH', None) oldlang = os.environ.pop('LANG', None) -try: +try: os.environ['PYTHONPATH'] = str(extrapath) -output = py.process.cmdexec('''"%s" "%s" -c "import urllib"''' % - (sys.executable, pypypath) ) -assert output.strip() == '42' -finally: -if old: -os.environ['PYTHONPATH'] = old +output = py.process.cmdexec('''"%s" "%s" -c "import urllib"''' % + (sys.executable, pypypath)) +assert output.strip() == '42' +finally: +if old: +os.environ['PYTHONPATH'] = old if oldlang: os.environ['LANG'] = oldlang + class AppTestImportHooks(object): -spaceconfig = dict(usemodules=('struct', 'itertools')) +spaceconfig = { +"usemodules": ['struct', 'itertools', 'rctime'], +} def setup_class(cls): mydir = os.path.dirname(__file__) @@ -1145,7 +1150,7 @@ sys.path_hooks.append(ImpWrapper) sys.path_importer_cache.clear() try: -mnames = ("colorsys", "urlparse", "distutils.core", "compiler.misc") +mnames = ("colorsys", "urlparse", "email.mime", "compiler.misc") for mname in mnames: parent = mname.split(".")[0] for n in sys.modules.keys(): diff --git a/pypy/module/itertools/test/test_itertools.py b/pypy/module/itertools/test/test_itertools.py --- a/pypy/module/itertools/test/test_itertools.py +++ b/pypy/module/itertools/test/test_itertools.py @@ -912,7 +912,9 @@ class AppTestItertools27: -spaceconfig = dict(usemodules=['itertools', 'struct']) +spaceconfig = { +"usemodules": ['itertools', 'struct', 'binascii'], +} def setup_class(cls): if cls.space.is_true(cls.space.appexec([], """(): diff --git a/pypy/module/micronumpy/test/test_complex.py b/pypy/module/micronumpy/test/test_complex.py --- a/pypy/module/micronumpy/test/test_complex.py +++ b/pypy/module/micronumpy/test/test_complex.py @@ -1,13 +1,16 @@ from __future__ import with_statement + import sys + +from pypy.conftest import option +from pypy.interpreter.error import OperationError +from pypy.interpreter.gateway import interp2app from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest from pypy.rlib.rfloat import isnan, isinf, copysign from pypy.rlib.rcomplex import c_pow -from pypy.interpreter.error import OperationError -from pypy.conftest import option -def rAlmostEqual(a, b, rel_err = 2e-15, abs_err = 5e-323, msg='', isnumpy=False): +def rAlmostEqual(a, b, rel_err=2e-15, abs_err=5e-323, msg='', isnumpy=False): """Fail if the two floating-point numbers are not almost equal. Determine whether floating-point values a and b are equal to within @@ -90,23 +93,31 @@ fname64 = os.path.join(os.path.dirname(__file__), 'complex64_testcases.txt') cls.w_testcases128 = cls.space.wrap(list(parse_testfile(fname128))) cls.w_testcases64 = cls.space.wrap(list(parse_testfile(fname64))) -def cls_c_pow(self, *args): + +def cls_
[pypy-commit] pypy kill-faking: fix thread tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59235:aa12b7a661df Date: 2012-12-02 13:49 -0800 http://bitbucket.org/pypy/pypy/changeset/aa12b7a661df/ Log:fix thread tests diff --git a/pypy/module/thread/test/support.py b/pypy/module/thread/test/support.py --- a/pypy/module/thread/test/support.py +++ b/pypy/module/thread/test/support.py @@ -1,11 +1,15 @@ -import py -import time, gc, thread, os -from pypy.interpreter.gateway import ObjSpace, W_Root, interp2app_temp +import gc +import time +import thread +import os + +from pypy.interpreter.gateway import interp2app, unwrap_spec from pypy.module.thread import gil NORMAL_TIMEOUT = 300.0 # 5 minutes + def waitfor(space, w_condition, delay=1): adaptivedelay = 0.04 limit = time.time() + delay * NORMAL_TIMEOUT @@ -19,6 +23,7 @@ adaptivedelay *= 1.05 print '*** timed out ***' + def timeout_killer(pid, delay): def kill(): for x in range(delay * 10): @@ -28,6 +33,7 @@ print "process %s killed!" % (pid,) thread.start_new_thread(kill, ()) + class GenericTestThread: spaceconfig = dict(usemodules=('thread', 'time', 'signal')) @@ -43,15 +49,26 @@ return adaptivedelay *= 1.05 print '*** timed out ***' - + cls.w_waitfor = plain_waitfor else: -cls.w_waitfor = cls.space.wrap( -lambda self, condition, delay=1: waitfor(cls.space, condition, delay)) +@unwrap_spec(delay=int) +def py_waitfor(space, w_condition, delay=1): +waitfor(space, w_condition, delay) + +cls.w_waitfor = cls.space.wrap(interp2app(py_waitfor)) cls.w_busywait = cls.space.appexec([], """(): import time return time.sleep """) - -cls.w_timeout_killer = cls.space.wrap( -lambda self, *args, **kwargs: timeout_killer(*args, **kwargs)) + +def py_timeout_killer(space, __args__): +args_w, kwargs_w = __args__.unpack() +args = map(space.unwrap, args_w) +kwargs = dict([ +(k, space.unwrap(v)) +for k, v in kwargs_w.iteritems() +]) +timeout_killer(*args, **kwargs) + +cls.w_timeout_killer = cls.space.wrap(interp2app(py_timeout_killer)) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix test_insecure_pickle
Author: Philip Jenvey Branch: Changeset: r59237:5ec61ffcc909 Date: 2012-12-02 13:59 -0800 http://bitbucket.org/pypy/pypy/changeset/5ec61ffcc909/ Log:fix test_insecure_pickle diff --git a/pypy/module/_codecs/test/test_codecs.py b/pypy/module/_codecs/test/test_codecs.py --- a/pypy/module/_codecs/test/test_codecs.py +++ b/pypy/module/_codecs/test/test_codecs.py @@ -2,7 +2,7 @@ class AppTestCodecs: -spaceconfig = dict(usemodules=('unicodedata', 'struct')) +spaceconfig = dict(usemodules=('binascii', 'struct', 'unicodedata')) def test_register_noncallable(self): import _codecs ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-globals-in-jit: Add a sanity check.
Author: Armin Rigo Branch: remove-globals-in-jit Changeset: r59238:f892171caf43 Date: 2012-12-02 14:08 -0800 http://bitbucket.org/pypy/pypy/changeset/f892171caf43/ Log:Add a sanity check. diff --git a/pypy/jit/metainterp/resume.py b/pypy/jit/metainterp/resume.py --- a/pypy/jit/metainterp/resume.py +++ b/pypy/jit/metainterp/resume.py @@ -1085,6 +1085,9 @@ def consume_virtualref_info(self, vrefinfo, numb, end): # we have to decode a list of references containing pairs # [..., virtual, vref, ...] stopping at 'end' +if vrefinfo is None: +assert end == 0 +return assert (end & 1) == 0 for i in range(0, end, 2): virtual = self.decode_ref(numb.nums[i]) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-globals-in-jit: Fix
Author: Armin Rigo Branch: remove-globals-in-jit Changeset: r59239:3f59cdbc4c52 Date: 2012-12-02 14:11 -0800 http://bitbucket.org/pypy/pypy/changeset/3f59cdbc4c52/ Log:Fix diff --git a/pypy/jit/metainterp/resume.py b/pypy/jit/metainterp/resume.py --- a/pypy/jit/metainterp/resume.py +++ b/pypy/jit/metainterp/resume.py @@ -706,9 +706,9 @@ # allocate() methods must fill in the cache as soon as they # have the object, before they fill its fields. assert self.virtuals_cache is not None -assert self.rd_virtuals is not None v = self.virtuals_cache[index] if not v: +assert self.rd_virtuals is not None v = self.rd_virtuals[index].allocate(self, index) ll_assert(v == self.virtuals_cache[index], "resume.py: bad cache") return v ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fix _contiuation
Author: Alex Gaynor Branch: kill-faking Changeset: r59240:590ec61489d7 Date: 2012-12-02 14:02 -0800 http://bitbucket.org/pypy/pypy/changeset/590ec61489d7/ Log:fix _contiuation diff --git a/pypy/module/_continuation/test/test_zpickle.py b/pypy/module/_continuation/test/test_zpickle.py --- a/pypy/module/_continuation/test/test_zpickle.py +++ b/pypy/module/_continuation/test/test_zpickle.py @@ -101,9 +101,11 @@ class AppTestPickle: version = 0 -spaceconfig = dict(usemodules=['_continuation', 'struct'], - continuation=True, - CALL_METHOD=True) +spaceconfig = { +"usemodules": ['_continuation', 'struct', 'binascii'], +"continuation": True, +"CALL_METHOD": True, +} def setup_class(cls): cls.space.appexec([], """(): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fixed _codecs tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59242:a7d77b6a4091 Date: 2012-12-02 14:05 -0800 http://bitbucket.org/pypy/pypy/changeset/a7d77b6a4091/ Log:fixed _codecs tests diff --git a/pypy/module/_codecs/test/test_codecs.py b/pypy/module/_codecs/test/test_codecs.py --- a/pypy/module/_codecs/test/test_codecs.py +++ b/pypy/module/_codecs/test/test_codecs.py @@ -2,7 +2,9 @@ class AppTestCodecs: -spaceconfig = dict(usemodules=('unicodedata', 'struct')) +spaceconfig = { +"usemodules": ['unicodedata', 'struct', 'binascii'], +} def test_register_noncallable(self): import _codecs @@ -19,7 +21,7 @@ def test_ucs4(self): x = u'\U0010' y = x.encode("raw-unicode-escape").decode("raw-unicode-escape") -assert x == y +assert x == y def test_named_unicode(self): assert unicode('\\N{SPACE}','unicode-escape') == u" " ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fix ast tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59241:fce7558cb9ee Date: 2012-12-02 14:04 -0800 http://bitbucket.org/pypy/pypy/changeset/fce7558cb9ee/ Log:fix ast tests diff --git a/pypy/module/_ast/test/test_ast.py b/pypy/module/_ast/test/test_ast.py --- a/pypy/module/_ast/test/test_ast.py +++ b/pypy/module/_ast/test/test_ast.py @@ -1,7 +1,10 @@ import py + class AppTestAST: -spaceconfig = dict(usemodules=['struct']) +spaceconfig = { +"usemodules": ['struct', 'binascii'], +} def setup_class(cls): cls.w_ast = cls.space.getbuiltinmodule('_ast') ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fix _lsprof tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59244:bd23a9f6b5d2 Date: 2012-12-02 14:23 -0800 http://bitbucket.org/pypy/pypy/changeset/bd23a9f6b5d2/ Log:fix _lsprof tests diff --git a/pypy/module/_lsprof/test/test_cprofile.py b/pypy/module/_lsprof/test/test_cprofile.py --- a/pypy/module/_lsprof/test/test_cprofile.py +++ b/pypy/module/_lsprof/test/test_cprofile.py @@ -1,5 +1,7 @@ class AppTestCProfile(object): -spaceconfig = dict(usemodules=('_lsprof',)) +spaceconfig = { +"usemodules": ['_lsprof', 'rctime'], +} def setup_class(cls): cls.w_expected_output = cls.space.wrap(expected_output) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fix _file test
Author: Alex Gaynor Branch: kill-faking Changeset: r59243:b482ae4ddd11 Date: 2012-12-02 14:18 -0800 http://bitbucket.org/pypy/pypy/changeset/b482ae4ddd11/ Log:fix _file test diff --git a/pypy/module/_file/test/test_file_extra.py b/pypy/module/_file/test/test_file_extra.py --- a/pypy/module/_file/test/test_file_extra.py +++ b/pypy/module/_file/test/test_file_extra.py @@ -207,15 +207,19 @@ assert repr(self.file).startswith( "http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: encoding error handlers now return unicode or strs to encoders so they can
Author: Philip Jenvey Branch: Changeset: r59245:66eb9aa93bb4 Date: 2012-12-02 14:30 -0800 http://bitbucket.org/pypy/pypy/changeset/66eb9aa93bb4/ Log:encoding error handlers now return unicode or strs to encoders so they can special case bytes results on py3 diff --git a/pypy/module/_codecs/interp_codecs.py b/pypy/module/_codecs/interp_codecs.py --- a/pypy/module/_codecs/interp_codecs.py +++ b/pypy/module/_codecs/interp_codecs.py @@ -9,15 +9,19 @@ self.codec_search_cache = {} self.codec_error_registry = {} self.codec_need_encodings = True -self.decode_error_handler = self.make_errorhandler(space, True) -self.encode_error_handler = self.make_errorhandler(space, False) +self.decode_error_handler = self.make_decode_errorhandler(space) +self.encode_error_handler = self.make_encode_errorhandler(space) self.unicodedata_handler = None -def make_errorhandler(self, space, decode): -def unicode_call_errorhandler(errors, encoding, reason, input, - startpos, endpos): +def _make_errorhandler(self, space, decode): +def call_errorhandler(errors, encoding, reason, input, startpos, + endpos): +"""Generic wrapper for calling into error handlers. +Returns (unicode_or_none, str_or_none, newpos) as error +handlers may return unicode or on Python 3, bytes. +""" w_errorhandler = lookup_error(space, errors) if decode: w_cls = space.w_UnicodeDecodeError @@ -55,7 +59,19 @@ "position %d from error handler out of bounds", newpos) replace = space.unicode_w(w_replace) return replace, newpos -return unicode_call_errorhandler +return call_errorhandler + +def make_decode_errorhandler(self, space): +return self._make_errorhandler(space, True) + +def make_encode_errorhandler(self, space): +errorhandler = self._make_errorhandler(space, False) +def encode_call_errorhandler(errors, encoding, reason, input, startpos, + endpos): +replace, newpos = errorhandler(errors, encoding, reason, input, + startpos, endpos) +return replace, None, newpos +return encode_call_errorhandler def get_unicodedata_handler(self, space): if self.unicodedata_handler: diff --git a/pypy/module/_multibytecodec/c_codecs.py b/pypy/module/_multibytecodec/c_codecs.py --- a/pypy/module/_multibytecodec/c_codecs.py +++ b/pypy/module/_multibytecodec/c_codecs.py @@ -279,10 +279,14 @@ replace = "?" else: assert errorcb -ret, end = errorcb(errors, namecb, reason, - unicodedata, start, end) -codec = pypy_cjk_enc_getcodec(encodebuf) -replace = encode(codec, ret, "strict", errorcb, namecb) +retu, rets, end = errorcb(errors, namecb, reason, + unicodedata, start, end) +if rets is not None: +# py3k only +replace = rets +else: +codec = pypy_cjk_enc_getcodec(encodebuf) +replace = encode(codec, retu, "strict", errorcb, namecb) inbuf = rffi.get_nonmovingbuffer(replace) try: r = pypy_cjk_enc_replace_on_error(encodebuf, inbuf, len(replace), end) diff --git a/pypy/module/_multibytecodec/test/test_app_codecs.py b/pypy/module/_multibytecodec/test/test_app_codecs.py --- a/pypy/module/_multibytecodec/test/test_app_codecs.py +++ b/pypy/module/_multibytecodec/test/test_app_codecs.py @@ -102,3 +102,11 @@ repl = u"\u2014" s = u"\uDDA1".encode("gbk", "test.multi_bad_handler") assert s == '\xA1\xAA' + +def test_encode_custom_error_handler_type(self): +import codecs +import sys +codecs.register_error("test.test_encode_custom_error_handler_type", + lambda e: ('\xc3', e.end)) +raises(TypeError, u"\uDDA1".encode, "gbk", + "test.test_encode_custom_error_handler_type") diff --git a/pypy/module/_multibytecodec/test/test_c_codecs.py b/pypy/module/_multibytecodec/test/test_c_codecs.py --- a/pypy/module/_multibytecodec/test/test_c_codecs.py +++ b/pypy/module/_multibytecodec/test/test_c_codecs.py @@ -122,3 +122,10 @@ c = getcodec('iso2022_jp') s = encode(c, u'\u83ca\u5730\u6642\u592b') assert s == '\x1b$B5FCO;~IW\x1b(B' and type(s) is str + +def test_encode_custom_error_handler_bytes(): +c = getcodec("hz") +def errorhandler(errors, enc, msg, t, startingpos, endingpos): +return None, '\xc3', endingpos +s = encode(c, u'abc\u1234def', 'foo', errorhandler) +assert '\xc3' in s diff --git a/pypy/rlib/runicode.py b/pypy/rlib/runicode.py --- a/pypy/rlib/runicode.py +++ b/pypy/rlib/runicode.py @@ -5
[pypy-commit] pypy kill-faking: fix some of the md5 tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59246:1672d40d225c Date: 2012-12-02 14:24 -0800 http://bitbucket.org/pypy/pypy/changeset/1672d40d225c/ Log:fix some of the md5 tests diff --git a/pypy/module/_md5/test/test_md5.py b/pypy/module/_md5/test/test_md5.py --- a/pypy/module/_md5/test/test_md5.py +++ b/pypy/module/_md5/test/test_md5.py @@ -4,7 +4,9 @@ class AppTestMD5(object): -spaceconfig = dict(usemodules=['_md5']) +spaceconfig = { +"usemodules": ['_md5', 'rctime'], +} def setup_class(cls): cls.w_md5 = cls.space.appexec([], """(): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fix _sha tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59248:93b2eca602c8 Date: 2012-12-02 14:28 -0800 http://bitbucket.org/pypy/pypy/changeset/93b2eca602c8/ Log:fix _sha tests diff --git a/pypy/module/_sha/test/test_sha.py b/pypy/module/_sha/test/test_sha.py --- a/pypy/module/_sha/test/test_sha.py +++ b/pypy/module/_sha/test/test_sha.py @@ -2,11 +2,11 @@ Tests for the sha module implemented at interp-level in pypy/module/sha. """ -import py - class AppTestSHA(object): -spaceconfig = dict(usemodules=['_sha']) +spaceconfig = { +"usemodules": ['_sha', 'rctime'], +} def setup_class(cls): cls.w_sha = cls.space.appexec([], """(): @@ -14,7 +14,6 @@ return sha """) - def test_digest_size(self): """ Check some numeric values from the sha module. ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fixed _random tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59247:3f6f4b47fa94 Date: 2012-12-02 14:27 -0800 http://bitbucket.org/pypy/pypy/changeset/3f6f4b47fa94/ Log:fixed _random tests diff --git a/pypy/module/_random/test/test_random.py b/pypy/module/_random/test/test_random.py --- a/pypy/module/_random/test/test_random.py +++ b/pypy/module/_random/test/test_random.py @@ -1,5 +1,7 @@ class AppTestRandom: -spaceconfig = dict(usemodules=['_random']) +spaceconfig = { +"usemodules": ['_random', 'rctime'], +} def test_dict(self): import _random ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fix _ssl tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59249:ed63256b3053 Date: 2012-12-02 14:31 -0800 http://bitbucket.org/pypy/pypy/changeset/ed63256b3053/ Log:fix _ssl tests diff --git a/pypy/module/_ssl/test/test_ssl.py b/pypy/module/_ssl/test/test_ssl.py --- a/pypy/module/_ssl/test/test_ssl.py +++ b/pypy/module/_ssl/test/test_ssl.py @@ -82,7 +82,9 @@ class AppTestConnectedSSL: -spaceconfig = dict(usemodules=('_ssl', '_socket', 'struct')) +spaceconfig = { +"usemodules": ['_ssl', '_socket', 'struct', 'binascii'], +} def setup_method(self, method): # https://www.verisign.net/ @@ -165,10 +167,13 @@ raises(ssl.SSLError, ss.write, "hello\n") del ss; gc.collect() + class AppTestConnectedSSL_Timeout(AppTestConnectedSSL): # Same tests, with a socket timeout # to exercise the poll() calls -spaceconfig = dict(usemodules=('_ssl', '_socket', 'struct')) +spaceconfig = { +"usemodules": ['_ssl', '_socket', 'struct', 'binascii'], +} def setup_class(cls): cls.space.appexec([], """(): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fix posix tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59251:5c11c8cf8df7 Date: 2012-12-02 14:39 -0800 http://bitbucket.org/pypy/pypy/changeset/5c11c8cf8df7/ Log:fix posix tests diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py --- a/pypy/module/posix/test/test_posix2.py +++ b/pypy/module/posix/test/test_posix2.py @@ -51,7 +51,7 @@ class AppTestPosix: spaceconfig = { -"usemodules": ["binascii", "struct"], +"usemodules": ["binascii", "struct", "rctime"], } def setup_class(cls): diff --git a/pypy/module/posix/test/test_posix_libfile.py b/pypy/module/posix/test/test_posix_libfile.py --- a/pypy/module/posix/test/test_posix_libfile.py +++ b/pypy/module/posix/test/test_posix_libfile.py @@ -1,24 +1,29 @@ +import os + from pypy.tool.udir import udir -import os + def setup_module(mod): mod.path = udir.join('test_posix_libfile.txt') mod.path.write("this is a test") -class AppTestPosix: -spaceconfig = dict(usemodules=['posix']) -def setup_class(cls): +class AppTestPosix: +spaceconfig = { +"usemodules": ['posix', 'rctime'], +} + +def setup_class(cls): cls.w_posix = cls.space.appexec([], """(): import %s as m ; return m""" % os.name) cls.w_path = cls.space.wrap(str(path)) - -def test_posix_is_pypy_s(self): -assert self.posix.__file__ + +def test_posix_is_pypy_s(self): +assert self.posix.__file__ def test_fdopen(self): -path = self.path -posix = self.posix +path = self.path +posix = self.posix fd = posix.open(path, posix.O_RDONLY, 0777) f = posix.fdopen(fd, "r") result = f.read() ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fix up the micronumpy test
Author: Alex Gaynor Branch: kill-faking Changeset: r59250:144813ec54a6 Date: 2012-12-02 14:34 -0800 http://bitbucket.org/pypy/pypy/changeset/144813ec54a6/ Log:fix up the micronumpy test diff --git a/pypy/module/micronumpy/test/test_ufuncs.py b/pypy/module/micronumpy/test/test_ufuncs.py --- a/pypy/module/micronumpy/test/test_ufuncs.py +++ b/pypy/module/micronumpy/test/test_ufuncs.py @@ -1,17 +1,17 @@ - +from pypy.conftest import option +from pypy.interpreter.gateway import interp2app from pypy.module.micronumpy.test.test_base import BaseNumpyAppTest from pypy.rlib.rcomplex import c_pow -from pypy.conftest import option - class AppTestUfuncs(BaseNumpyAppTest): def setup_class(cls): import os BaseNumpyAppTest.setup_class.im_func(cls) -def cls_c_pow(self, *args): -return c_pow(*args) -cls.w_c_pow = cls.space.wrap(cls_c_pow) + +def cls_c_pow(space, args_w): +return space.wrap(c_pow(*map(space.unwrap, args_w))) +cls.w_c_pow = cls.space.wrap(interp2app(cls_c_pow)) cls.w_runAppDirect = cls.space.wrap(option.runappdirect) cls.w_isWindows = cls.space.wrap(os.name == 'nt') ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fix rctime tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59252:a77e23aba3e3 Date: 2012-12-02 14:41 -0800 http://bitbucket.org/pypy/pypy/changeset/a77e23aba3e3/ Log:fix rctime tests diff --git a/pypy/module/rctime/test/test_rctime.py b/pypy/module/rctime/test/test_rctime.py --- a/pypy/module/rctime/test/test_rctime.py +++ b/pypy/module/rctime/test/test_rctime.py @@ -1,5 +1,7 @@ class AppTestRCTime: -spaceconfig = dict(usemodules=['rctime', 'struct']) +spaceconfig = { +"usemodules": ['rctime', 'struct', 'binascii'], +} def test_attributes(self): import time as rctime ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fixed signal and epoll tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59253:617dcec9d57b Date: 2012-12-02 14:43 -0800 http://bitbucket.org/pypy/pypy/changeset/617dcec9d57b/ Log:fixed signal and epoll tests diff --git a/pypy/module/select/test/test_epoll.py b/pypy/module/select/test/test_epoll.py --- a/pypy/module/select/test/test_epoll.py +++ b/pypy/module/select/test/test_epoll.py @@ -4,8 +4,11 @@ # add a larger timeout for slow ARM machines import platform + class AppTestEpoll(object): -spaceconfig = dict(usemodules=["select", "_socket", "posix"]) +spaceconfig = { +"usemodules": ["select", "_socket", "posix", "rctime"], +} def setup_class(cls): # NB. we should ideally py.test.skip() if running on an old linux diff --git a/pypy/module/signal/test/test_signal.py b/pypy/module/signal/test/test_signal.py --- a/pypy/module/signal/test/test_signal.py +++ b/pypy/module/signal/test/test_signal.py @@ -8,7 +8,7 @@ def setup_class(cls): if not hasattr(os, 'kill') or not hasattr(os, 'getpid'): py.test.skip("requires os.kill() and os.getpid()") -if not hasattr(cpy_signal, 'SIGUSR1'): +if not hasattr(cpy_signal, 'SIGUSR1'): py.test.skip("requires SIGUSR1 in signal") def test_checksignals(self): @@ -35,7 +35,9 @@ class AppTestSignal: -spaceconfig = dict(usemodules=['signal']) +spaceconfig = { +"usemodules": ['signal', 'rctime'], +} def setup_class(cls): cls.w_signal = cls.space.getbuiltinmodule('signal') @@ -52,7 +54,7 @@ if not hasattr(os, 'kill') or not hasattr(os, 'getpid'): skip("requires os.kill() and os.getpid()") signal = self.signal # the signal module to test -if not hasattr(signal, 'SIGUSR1'): +if not hasattr(signal, 'SIGUSR1'): py.test.skip("requires SIGUSR1 in signal") signum = signal.SIGUSR1 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fixed zipimport tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59254:75afd802017d Date: 2012-12-02 14:51 -0800 http://bitbucket.org/pypy/pypy/changeset/75afd802017d/ Log:fixed zipimport tests diff --git a/pypy/module/zipimport/test/test_zipimport.py b/pypy/module/zipimport/test/test_zipimport.py --- a/pypy/module/zipimport/test/test_zipimport.py +++ b/pypy/module/zipimport/test/test_zipimport.py @@ -7,17 +7,19 @@ from StringIO import StringIO from pypy.tool.udir import udir -from zipfile import ZIP_STORED, ZIP_DEFLATED, ZipInfo +from zipfile import ZIP_STORED, ZIP_DEFLATED + class AppTestZipimport: """ A bit structurized tests stolen and adapted from cpy's regression tests """ compression = ZIP_STORED -spaceconfig = dict(usemodules=['zipimport', 'rctime', 'struct', - 'itertools']) +spaceconfig = { +"usemodules": ['zipimport', 'rctime', 'struct', 'itertools', 'binascii'], +} pathsep = os.path.sep - + @classmethod def make_pyc(cls, space, co, mtime): data = marshal.dumps(co) @@ -48,7 +50,7 @@ def get_file(): return __file__ """).compile() - + space = cls.space tmpdir = udir.ensure('zipimport_%s' % cls.__name__, dir=1) @@ -61,7 +63,6 @@ #ziptestmodule = tmpdir.ensure('ziptestmodule.zip').write( ziptestmodule = tmpdir.join("somezip.zip") cls.w_tmpzip = space.wrap(str(ziptestmodule)) -cls.w_co = space.wrap(co) cls.tmpdir = tmpdir def setup_class(cls): @@ -162,7 +163,7 @@ for key, val in expected.items(): assert mod.__dict__[key] == val assert mod.__file__.endswith('.zip'+os.sep+'uuu.py') - + def test_pyc(self): import sys, os self.writefile("uuu.pyc", self.test_pyc) @@ -312,7 +313,7 @@ def test_subdirectory_twice(self): #import os, zipimport - + self.writefile("package/__init__.py", "") self.writefile("package/subpackage/__init__.py", "") self.writefile("package/subpackage/foo.py", "") @@ -355,8 +356,9 @@ class AppTestZipimportDeflated(AppTestZipimport): compression = ZIP_DEFLATED -spaceconfig = dict(usemodules=['zipimport', 'zlib', 'rctime', 'struct', - 'itertools']) +spaceconfig = { +"usemodules": ['zipimport', 'zlib', 'rctime', 'struct', 'itertools', 'binascii'], +} def setup_class(cls): try: ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: remove a test for a feature which was removed
Author: Alex Gaynor Branch: kill-faking Changeset: r59255:dde805ff7ad0 Date: 2012-12-02 14:51 -0800 http://bitbucket.org/pypy/pypy/changeset/dde805ff7ad0/ Log:remove a test for a feature which was removed diff --git a/pypy/tool/pytest/test/test_pytestsupport.py b/pypy/tool/pytest/test/test_pytestsupport.py --- a/pypy/tool/pytest/test/test_pytestsupport.py +++ b/pypy/tool/pytest/test/test_pytestsupport.py @@ -80,21 +80,6 @@ assert not appex.errisinstance(A) -def test_fakedexception(space): -from cPickle import PicklingError -def raise_error(): -raise PicklingError("SomeMessage") -space.setitem(space.builtin.w_dict, space.wrap('raise_error'), - space.wrap(raise_error)) - -try: -space.appexec([], "(): raise_error()") -except OperationError, e: -appex = AppExceptionInfo(space, e) -else: -py.test.fail("did not raise!") -assert "PicklingError" in appex.exconly() - class AppTestWithWrappedInterplevelAttributes: def setup_class(cls): space = cls.space ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: hg merge default
Author: Amaury Forgeot d'Arc Branch: py3k Changeset: r59256:61ec51116bd6 Date: 2012-12-02 11:34 +0100 http://bitbucket.org/pypy/pypy/changeset/61ec51116bd6/ Log:hg merge default diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py --- a/pypy/objspace/std/objspace.py +++ b/pypy/objspace/std/objspace.py @@ -50,7 +50,6 @@ self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_StringObject - self.UnicodeObjectCls = W_UnicodeObject self._install_multimethods() diff --git a/pypy/tool/pytest/objspace.py b/pypy/tool/pytest/objspace.py --- a/pypy/tool/pytest/objspace.py +++ b/pypy/tool/pytest/objspace.py @@ -10,7 +10,7 @@ """ helper for instantiating and caching space's for testing. """ try: -config = make_config(option,**kwds) +config = make_config(option, **kwds) except ConflictConfigError as e: # this exception is typically only raised if a module is not available. # in this case the test should be skipped ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: cpyext: remove from stubs.py already implemented function
Author: Amaury Forgeot d'Arc Branch: py3k Changeset: r59258:068fd4a03cd3 Date: 2012-12-02 14:38 +0100 http://bitbucket.org/pypy/pypy/changeset/068fd4a03cd3/ Log:cpyext: remove from stubs.py already implemented function diff --git a/pypy/module/cpyext/stubs.py b/pypy/module/cpyext/stubs.py --- a/pypy/module/cpyext/stubs.py +++ b/pypy/module/cpyext/stubs.py @@ -1645,33 +1645,6 @@ raise NotImplementedError -@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL) -def PyInstanceMethod_Check(space, o): -"""Return true if o is an instance method object (has type -PyInstanceMethod_Type). The parameter must not be NULL.""" -raise NotImplementedError - - -@cpython_api([PyObject], PyObject) -def PyInstanceMethod_New(space, func): -"""Return a new instance method object, with func being any callable object -func is the function that will be called when the instance method is -called.""" -raise NotImplementedError - - -@cpython_api([PyObject], PyObject) -def PyInstanceMethod_Function(space, im): -"""Return the function object associated with the instance method im.""" -raise NotImplementedError - - -@cpython_api([PyObject], PyObject) -def PyInstanceMethod_GET_FUNCTION(space, im): -"""Macro version of PyInstanceMethod_Function() which avoids error checking.""" -raise NotImplementedError - - @cpython_api([], rffi.INT_real, error=-1) def PyMethod_ClearFreeList(space, ): """Clear the free list. Return the total number of freed items.""" ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: Only search encoding for Python source files.
Author: Amaury Forgeot d'Arc Branch: py3k Changeset: r59259:0e46137d618b Date: 2012-12-02 14:55 +0100 http://bitbucket.org/pypy/pypy/changeset/0e46137d618b/ Log:Only search encoding for Python source files. Binary files may not be opened with an "encoding" parameter... diff --git a/pypy/module/imp/interp_imp.py b/pypy/module/imp/interp_imp.py --- a/pypy/module/imp/interp_imp.py +++ b/pypy/module/imp/interp_imp.py @@ -73,14 +73,15 @@ stream = find_info.stream if stream is not None: -# try to find the declared encoding encoding = None -firstline = stream.readline() -stream.seek(0, 0) # reset position -if firstline.startswith('#'): -encoding = pytokenizer.match_encoding_declaration(firstline) -if encoding is None: -encoding = unicodetype.getdefaultencoding(space) +if find_info.modtype == importing.PY_SOURCE: +# try to find the declared encoding +firstline = stream.readline() +stream.seek(0, 0) # reset position +if firstline.startswith('#'): +encoding = pytokenizer.match_encoding_declaration(firstline) +if encoding is None: +encoding = unicodetype.getdefaultencoding(space) # # in python2, both CPython and PyPy pass the filename to # open(). However, CPython 3 just passes the fd, so the returned file ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fix __pypy__ tests (removed isfake, nothing is fake!)
Author: Alex Gaynor Branch: kill-faking Changeset: r59263:e7c95429e35c Date: 2012-12-02 14:59 -0800 http://bitbucket.org/pypy/pypy/changeset/e7c95429e35c/ Log:fix __pypy__ tests (removed isfake, nothing is fake!) diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py --- a/pypy/module/__pypy__/__init__.py +++ b/pypy/module/__pypy__/__init__.py @@ -59,7 +59,6 @@ def setup_after_space_initialization(self): """NOT_RPYTHON""" if not self.space.config.translating: -self.extra_interpdef('isfake', 'interp_magic.isfake') self.extra_interpdef('interp_pdb', 'interp_magic.interp_pdb') if self.space.config.objspace.std.withmethodcachecounter: self.extra_interpdef('method_cache_counter', diff --git a/pypy/module/__pypy__/interp_magic.py b/pypy/module/__pypy__/interp_magic.py --- a/pypy/module/__pypy__/interp_magic.py +++ b/pypy/module/__pypy__/interp_magic.py @@ -7,16 +7,10 @@ from pypy.objspace.std.mapdict import IndexCache from pypy.rlib import rposix + def internal_repr(space, w_object): return space.wrap('%r' % (w_object,)) -def isfake(space, w_obj): -"""Return whether the argument is faked (stolen from CPython). This is -always False after translation.""" -if we_are_translated(): -return space.w_False -return space.wrap(bool(w_obj.typedef.fakedcpytype)) -#return space.wrap(bool(getattr(w_obj.typedef, 'fakedcpytype', None))) def interp_pdb(space): """Run an interp-level pdb. @@ -25,6 +19,7 @@ import pdb pdb.set_trace() + @unwrap_spec(name=str) def method_cache_counter(space, name): """Return a tuple (method_cache_hits, method_cache_misses) for calls to diff --git a/pypy/module/__pypy__/test/test_debug.py b/pypy/module/__pypy__/test/test_debug.py --- a/pypy/module/__pypy__/test/test_debug.py +++ b/pypy/module/__pypy__/test/test_debug.py @@ -1,13 +1,16 @@ import py + +from pypy.interpreter.gateway import interp2app from pypy.rlib import debug + class AppTestDebug: spaceconfig = dict(usemodules=['__pypy__']) def setup_class(cls): if cls.runappdirect: py.test.skip("not meant to be run with -A") -cls.w_check_log = cls.space.wrap(cls.check_log) +cls.w_check_log = cls.space.wrap(interp2app(cls.check_log)) def setup_method(self, meth): debug._log = debug.DebugLog() @@ -15,9 +18,9 @@ def teardown_method(self, meth): debug._log = None -@classmethod -def check_log(cls, expected): -assert list(debug._log) == expected +@staticmethod +def check_log(space, w_expected): +assert list(debug._log) == space.unwrap(w_expected) def test_debug_print(self): from __pypy__ import debug_start, debug_stop, debug_print diff --git a/pypy/module/__pypy__/test/test_special.py b/pypy/module/__pypy__/test/test_special.py --- a/pypy/module/__pypy__/test/test_special.py +++ b/pypy/module/__pypy__/test/test_special.py @@ -8,17 +8,6 @@ if cls.runappdirect: py.test.skip("does not make sense on pypy-c") -def test__isfake(self): -from __pypy__ import isfake -assert not isfake(map) -assert not isfake(object) -assert not isfake(isfake) - -def test__isfake_currently_true(self): -from __pypy__ import isfake -import select -assert isfake(select) - def test_cpumodel(self): import __pypy__ assert hasattr(__pypy__, 'cpumodel') ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: Fix os.fork() when run with bin/py.py with cpyext module enabled:
Author: Amaury Forgeot d'Arc Branch: py3k Changeset: r59257:24189046c0ca Date: 2012-12-02 14:38 +0100 http://bitbucket.org/pypy/pypy/changeset/24189046c0ca/ Log:Fix os.fork() when run with bin/py.py with cpyext module enabled: when interpreted, PyThread_ReInitTLS() is the one from the host CPython, and not the one provided by cpyext. Funny things will happen then, errors like "RuntimeError: not holding the import lock" diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py --- a/pypy/module/cpyext/api.py +++ b/pypy/module/cpyext/api.py @@ -650,8 +650,12 @@ lambda space: init_capsule(), ]) from pypy.module.posix.interp_posix import add_fork_hook -reinit_tls = rffi.llexternal('PyThread_ReInitTLS', [], lltype.Void, - compilation_info=eci) +if we_are_translated(): +reinit_tls = rffi.llexternal('PyThread_ReInitTLS', [], lltype.Void, + compilation_info=eci) +else: +reinit_tls = rffi.llexternal('PyPyThread_ReInitTLS', [], lltype.Void, + compilation_info=eci) add_fork_hook('child', reinit_tls) def init_function(func): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: PyInstanceMethod_Type is now implemented.
Author: Amaury Forgeot d'Arc Branch: py3k Changeset: r59260:573ac322df63 Date: 2012-12-02 15:04 +0100 http://bitbucket.org/pypy/pypy/changeset/573ac322df63/ Log:PyInstanceMethod_Type is now implemented. diff --git a/lib_pypy/_testcapimodule.c b/lib_pypy/_testcapimodule.c --- a/lib_pypy/_testcapimodule.c +++ b/lib_pypy/_testcapimodule.c @@ -1,5 +1,4 @@ -/* Verbatim copy of Modules/_testcapimodule.c from CPython 3.2 w/ use - of PyInstanceMethod disabled */ +/* Verbatim copy of Modules/_testcapimodule.c from CPython 3.2 */ /* * C Extension module to test Python interpreter C APIs. * @@ -2626,10 +2625,8 @@ PyModule_AddObject(m, "PY_SSIZE_T_MAX", PyLong_FromSsize_t(PY_SSIZE_T_MAX)); PyModule_AddObject(m, "PY_SSIZE_T_MIN", PyLong_FromSsize_t(PY_SSIZE_T_MIN)); PyModule_AddObject(m, "SIZEOF_PYGC_HEAD", PyLong_FromSsize_t(sizeof(PyGC_Head))); -#if 0 /* XXX: disabled for PyPy (for now) */ Py_INCREF(&PyInstanceMethod_Type); PyModule_AddObject(m, "instancemethod", (PyObject *)&PyInstanceMethod_Type); -#endif TestError = PyErr_NewException("_testcapi.error", NULL, NULL); Py_INCREF(TestError); ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: cpyext: implement PyMemoryView_FromBuffer
Author: Amaury Forgeot d'Arc Branch: py3k Changeset: r59261:033e22d48bf2 Date: 2012-12-02 23:36 +0100 http://bitbucket.org/pypy/pypy/changeset/033e22d48bf2/ Log:cpyext: implement PyMemoryView_FromBuffer diff --git a/pypy/module/cpyext/buffer.py b/pypy/module/cpyext/buffer.py --- a/pypy/module/cpyext/buffer.py +++ b/pypy/module/cpyext/buffer.py @@ -1,8 +1,8 @@ -from pypy.interpreter.error import OperationError from pypy.rpython.lltypesystem import rffi, lltype from pypy.module.cpyext.api import ( cpython_api, CANNOT_FAIL, Py_buffer) -from pypy.module.cpyext.pyobject import PyObject +from pypy.module.cpyext.pyobject import PyObject, Py_DecRef +from pypy.interpreter import buffer @cpython_api([lltype.Ptr(Py_buffer), lltype.Char], rffi.INT_real, error=CANNOT_FAIL) def PyBuffer_IsContiguous(space, view, fortran): @@ -11,3 +11,27 @@ (fortran is 'A'). Return 0 otherwise.""" # PyPy only supports contiguous Py_buffers for now. return 1 + +class CBufferMixin(object): +_mixin_ = True + +def __init__(self, space, c_buf, c_len, w_obj): +self.space = space +self.c_buf = c_buf +self.c_len = c_len +self.w_obj = w_obj + +def __del__(self): +Py_DecRef(self.space, self.w_obj) + +def getlength(self): +return self.c_len + +def getitem(self, index): +return self.c_buf[index] + +def as_str(self): +return rffi.charpsize2str(self.c_buf, self.c_len) + +class CBuffer(CBufferMixin, buffer.Buffer): +pass diff --git a/pypy/module/cpyext/memoryobject.py b/pypy/module/cpyext/memoryobject.py --- a/pypy/module/cpyext/memoryobject.py +++ b/pypy/module/cpyext/memoryobject.py @@ -1,6 +1,19 @@ -from pypy.module.cpyext.api import cpython_api -from pypy.module.cpyext.pyobject import PyObject +from pypy.module.cpyext.api import cpython_api, Py_buffer +from pypy.module.cpyext.pyobject import PyObject, from_ref +from pypy.module.cpyext.buffer import CBuffer +from pypy.rpython.lltypesystem import rffi, lltype +from pypy.module.__builtin__.interp_memoryview import W_MemoryView @cpython_api([PyObject], PyObject) def PyMemoryView_FromObject(space, w_obj): return space.call_method(space.builtin, "memoryview", w_obj) + +@cpython_api([lltype.Ptr(Py_buffer)], PyObject) +def PyMemoryView_FromBuffer(space, view): +"""Create a memoryview object wrapping the given buffer structure view. +The memoryview object then owns the buffer represented by view, which +means you shouldn't try to call PyBuffer_Release() yourself: it +will be done on deallocation of the memoryview object.""" +w_obj = from_ref(space, view.c_obj) +buf = CBuffer(space, view.c_buf, view.c_len, w_obj) +return space.wrap(W_MemoryView(space.wrap(buf))) diff --git a/pypy/module/cpyext/stubs.py b/pypy/module/cpyext/stubs.py --- a/pypy/module/cpyext/stubs.py +++ b/pypy/module/cpyext/stubs.py @@ -1610,15 +1610,6 @@ raise NotImplementedError -@cpython_api([Py_buffer], PyObject) -def PyMemoryView_FromBuffer(space, view): -"""Create a memoryview object wrapping the given buffer structure view. -The memoryview object then owns the buffer represented by view, which -means you shouldn't try to call PyBuffer_Release() yourself: it -will be done on deallocation of the memoryview object.""" -raise NotImplementedError - - @cpython_api([PyObject, rffi.INT_real, lltype.Char], PyObject) def PyMemoryView_GetContiguous(space, obj, buffertype, order): """Create a memoryview object to a contiguous chunk of memory (in either diff --git a/pypy/module/cpyext/test/test_memoryobject.py b/pypy/module/cpyext/test/test_memoryobject.py --- a/pypy/module/cpyext/test/test_memoryobject.py +++ b/pypy/module/cpyext/test/test_memoryobject.py @@ -1,5 +1,6 @@ import py from pypy.module.cpyext.test.test_api import BaseApiTest +from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase class TestMemoryViewObject(BaseApiTest): def test_fromobject(self, space, api): @@ -11,3 +12,29 @@ w_view = api.PyMemoryView_FromObject(w_hello) w_bytes = space.call_method(w_view, "tobytes") assert space.unwrap(w_bytes) == "hello" + +class AppTestPyBuffer_FillInfo(AppTestCpythonExtensionBase): +def test_fillWithObject(self): +module = self.import_extension('foo', [ +("fillinfo", "METH_VARARGS", + """ + Py_buffer buf; + PyObject *str = PyBytes_FromString("hello, world."); + PyObject *result; + + if (PyBuffer_FillInfo(&buf, str, PyBytes_AsString(str), 13, + 0, 0)) { + return NULL; + } + + /* Get rid of our own reference to the object, but + * the Py_buffer should still have a reference. + */ + Py_DECREF(str); + + return PyMemoryVi
[pypy-commit] pypy kill-faking: fix _ffi tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59262:203627c6ee85 Date: 2012-12-02 14:56 -0800 http://bitbucket.org/pypy/pypy/changeset/203627c6ee85/ Log:fix _ffi tests diff --git a/pypy/module/_ffi/test/test_struct.py b/pypy/module/_ffi/test/test_struct.py --- a/pypy/module/_ffi/test/test_struct.py +++ b/pypy/module/_ffi/test/test_struct.py @@ -1,7 +1,7 @@ -import sys +from pypy.interpreter.gateway import interp2app, unwrap_spec +from pypy.module._ffi.interp_ffitype import app_types, W_FFIType +from pypy.module._ffi.interp_struct import compute_size_and_alignement, W_Field from pypy.module._ffi.test.test_funcptr import BaseAppTestFFI -from pypy.module._ffi.interp_struct import compute_size_and_alignement, W_Field -from pypy.module._ffi.interp_ffitype import app_types, W_FFIType class TestStruct(object): @@ -37,12 +37,14 @@ assert self.sizeof([T.slonglong, T.sbyte, T.sbyte, T.sbyte]) == llong_size + llong_align assert self.sizeof([T.slonglong, T.sbyte, T.sbyte, T.sbyte, T.sbyte]) == llong_size + llong_align + class AppTestStruct(BaseAppTestFFI): def setup_class(cls): BaseAppTestFFI.setup_class.im_func(cls) -# -def read_raw_mem(self, addr, typename, length): + +@unwrap_spec(addr=int, typename=str, length=int) +def read_raw_mem(space, addr, typename, length): import ctypes addr = ctypes.cast(addr, ctypes.c_void_p) c_type = getattr(ctypes, typename) @@ -50,8 +52,8 @@ ptr_array = ctypes.cast(addr, array_type) array = ptr_array[0] lst = [array[i] for i in range(length)] -return lst -cls.w_read_raw_mem = cls.space.wrap(read_raw_mem) +return space.wrap(lst) +cls.w_read_raw_mem = cls.space.wrap(interp2app(read_raw_mem)) # from pypy.rlib import clibffi from pypy.rlib.rarithmetic import r_uint ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-globals-in-jit: Pff, this test passes when run untranslated, but crashes translated.
Author: Armin Rigo Branch: remove-globals-in-jit Changeset: r59264:73913dbe29d7 Date: 2012-12-02 15:13 -0800 http://bitbucket.org/pypy/pypy/changeset/73913dbe29d7/ Log:Pff, this test passes when run untranslated, but crashes translated. diff --git a/pypy/jit/metainterp/test/test_virtualizable.py b/pypy/jit/metainterp/test/test_virtualizable.py --- a/pypy/jit/metainterp/test/test_virtualizable.py +++ b/pypy/jit/metainterp/test/test_virtualizable.py @@ -1386,6 +1386,55 @@ print main(100) res = self.meta_interp(main, [100], inline=True, enable_opts='') +def test_stuff_from_backend_test(self): +class Thing(object): +def __init__(self, val): +self.val = val + +class Frame(object): +_virtualizable2_ = ['thing'] + +driver = JitDriver(greens = ['codeno'], reds = ['i', 'frame'], + virtualizables = ['frame'], + get_printable_location = lambda codeno: str(codeno)) +class SomewhereElse(object): +pass + +somewhere_else = SomewhereElse() + +@dont_look_inside +def change(newthing): +somewhere_else.frame.thing = newthing + +def main(codeno): +frame = Frame() +somewhere_else.frame = frame +frame.thing = Thing(0) +portal(codeno, frame) +return frame.thing.val + +def portal(codeno, frame): +i = 0 +while i < 10: +driver.can_enter_jit(frame=frame, codeno=codeno, i=i) +driver.jit_merge_point(frame=frame, codeno=codeno, i=i) +nextval = frame.thing.val +if codeno == 0: +subframe = Frame() +subframe.thing = Thing(nextval) +nextval = portal(1, subframe) +elif frame.thing.val > 40: +change(Thing(13)) +nextval = 13 +frame.thing = Thing(nextval + 1) +i += 1 +return frame.thing.val + +res = self.meta_interp(main, [0], inline=True) +print hex(res) +assert res == main(0) + + class TestOOtype(#ExplicitVirtualizableTests, ImplicitVirtualizableTests, OOJitMixin): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-globals-in-jit: Kill outdated code
Author: Armin Rigo Branch: remove-globals-in-jit Changeset: r59265:cebc974b0cb3 Date: 2012-12-02 15:15 -0800 http://bitbucket.org/pypy/pypy/changeset/cebc974b0cb3/ Log:Kill outdated code diff --git a/pypy/jit/metainterp/compile.py b/pypy/jit/metainterp/compile.py --- a/pypy/jit/metainterp/compile.py +++ b/pypy/jit/metainterp/compile.py @@ -715,23 +715,6 @@ hidden_all_virtuals = obj.hide(metainterp_sd.cpu) metainterp_sd.cpu.set_savedata_ref(deadframe, hidden_all_virtuals) -def fetch_data(self, key): -globaldata = self.metainterp_sd.globaldata -if we_are_translated(): -assert key in globaldata.resume_virtuals -data = globaldata.resume_virtuals[key] -del globaldata.resume_virtuals[key] -else: -rv = globaldata.resume_virtuals_not_translated -for i in range(len(rv)): -if rv[i][0] == key: -data = rv[i][1] -del rv[i] -break -else: -assert 0, "not found: %r" % (key,) -return data - def _clone_if_mutable(self): res = ResumeGuardForcedDescr(self.metainterp_sd, self.jitdriver_sd) diff --git a/pypy/jit/metainterp/virtualizable.py b/pypy/jit/metainterp/virtualizable.py --- a/pypy/jit/metainterp/virtualizable.py +++ b/pypy/jit/metainterp/virtualizable.py @@ -3,7 +3,6 @@ from pypy.rpython.annlowlevel import cast_base_ptr_to_instance from pypy.rpython.rclass import IR_IMMUTABLE_ARRAY, IR_IMMUTABLE from pypy.rpython import rvirtualizable2 -from pypy.rlib.objectmodel import we_are_translated from pypy.rlib.unroll import unrolling_iterable from pypy.rlib.nonconst import NonConstant from pypy.jit.metainterp.typesystem import deref, fieldType, arrayItem ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-globals-in-jit: Found out the magic incantation that makes ll2ctypes happy.
Author: Armin Rigo Branch: remove-globals-in-jit Changeset: r59266:53aa7dd2b299 Date: 2012-12-02 15:37 -0800 http://bitbucket.org/pypy/pypy/changeset/53aa7dd2b299/ Log:Found out the magic incantation that makes ll2ctypes happy. diff --git a/pypy/jit/metainterp/compile.py b/pypy/jit/metainterp/compile.py --- a/pypy/jit/metainterp/compile.py +++ b/pypy/jit/metainterp/compile.py @@ -649,6 +649,7 @@ return res class AllVirtuals: +llopaque = True list = [resume.ResumeDataDirectReader.virtual_default] # annotation hack def __init__(self, list): self.list = list diff --git a/pypy/jit/metainterp/test/test_recursive.py b/pypy/jit/metainterp/test/test_recursive.py --- a/pypy/jit/metainterp/test/test_recursive.py +++ b/pypy/jit/metainterp/test/test_recursive.py @@ -849,13 +849,7 @@ res = self.meta_interp(main, [0], inline=True) assert res == main(0) -def _skip_if_untranslated_on_a_real_backend(self): -if not hasattr(self.CPUClass, 'is_llgraph'): -py.test.skip("xxx only works on the llgraph backend, or " - "fully translated") - def test_directly_call_assembler_virtualizable_force1(self): -self._skip_if_untranslated_on_a_real_backend() class Thing(object): def __init__(self, val): self.val = val @@ -950,7 +944,6 @@ assert res == main(0, 10, 1) def test_directly_call_assembler_virtualizable_force_blackhole(self): -self._skip_if_untranslated_on_a_real_backend() class Thing(object): def __init__(self, val): self.val = val diff --git a/pypy/jit/metainterp/test/test_virtualizable.py b/pypy/jit/metainterp/test/test_virtualizable.py --- a/pypy/jit/metainterp/test/test_virtualizable.py +++ b/pypy/jit/metainterp/test/test_virtualizable.py @@ -660,13 +660,7 @@ self.check_aborted_count(3) self.check_jitcell_token_count(0) -def _skip_if_untranslated_on_a_real_backend(self): -if not hasattr(self.CPUClass, 'is_llgraph'): -py.test.skip("xxx only works on the llgraph backend, or " - "fully translated") - def test_external_read_sometimes(self): -self._skip_if_untranslated_on_a_real_backend() jitdriver = JitDriver(greens = [], reds = ['frame'], virtualizables = ['frame']) @@ -703,7 +697,6 @@ assert res == f(123) def test_external_read_sometimes_with_virtuals(self): -self._skip_if_untranslated_on_a_real_backend() jitdriver = JitDriver(greens = [], reds = ['frame'], virtualizables = ['frame']) @@ -747,7 +740,6 @@ assert res == f(123) def test_external_read_sometimes_changing_virtuals(self): -self._skip_if_untranslated_on_a_real_backend() jitdriver = JitDriver(greens = [], reds = ['frame'], virtualizables = ['frame']) @@ -796,7 +788,6 @@ assert res == f(123) def test_external_read_sometimes_with_exception(self): -self._skip_if_untranslated_on_a_real_backend() jitdriver = JitDriver(greens = [], reds = ['frame'], virtualizables = ['frame']) @@ -839,7 +830,6 @@ assert res == f(123) def test_external_read_sometimes_dont_compile_guard(self): -self._skip_if_untranslated_on_a_real_backend() jitdriver = JitDriver(greens = [], reds = ['frame'], virtualizables = ['frame']) @@ -876,7 +866,6 @@ assert res == f(123) def test_external_read_sometimes_recursive(self): -self._skip_if_untranslated_on_a_real_backend() jitdriver = JitDriver(greens = [], reds = ['rec', 'frame'], virtualizables = ['frame']) @@ -928,7 +917,6 @@ assert res == main(123) def test_external_write_sometimes(self): -self._skip_if_untranslated_on_a_real_backend() jitdriver = JitDriver(greens = [], reds = ['frame'], virtualizables = ['frame']) diff --git a/pypy/jit/metainterp/test/test_virtualref.py b/pypy/jit/metainterp/test/test_virtualref.py --- a/pypy/jit/metainterp/test/test_virtualref.py +++ b/pypy/jit/metainterp/test/test_virtualref.py @@ -285,13 +285,7 @@ new_array=6) # next1/2/3 self.check_aborted_count(0) -def _skip_if_untranslated_on_a_real_backend(self): -if not hasattr(self.CPUClass, 'is_llgraph'): -py.test.skip("xxx only works on the llgraph backend, or " - "fully translated") - def test_simple_force_sometimes(self): -self._skip_if_untranslated_on_a_real_backend() myjitdriver = JitDriver(greens = [], reds = ['n']) # A = lltype.GcArray(lltype.Signed) @@
[pypy-commit] pypy kill-faking: fixed _multiprocessing tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59267:0ffa477b714c Date: 2012-12-02 15:22 -0800 http://bitbucket.org/pypy/pypy/changeset/0ffa477b714c/ Log:fixed _multiprocessing tests diff --git a/pypy/module/_multiprocessing/test/test_connection.py b/pypy/module/_multiprocessing/test/test_connection.py --- a/pypy/module/_multiprocessing/test/test_connection.py +++ b/pypy/module/_multiprocessing/test/test_connection.py @@ -89,40 +89,43 @@ return multiprocessing.Pipe(duplex=False) + class AppTestSocketConnection(BaseConnectionTest): -spaceconfig = dict(usemodules=('_multiprocessing', 'thread', 'signal', - 'struct', 'array', 'itertools')) +spaceconfig = { +"usemodules": [ +'_multiprocessing', 'thread', 'signal', 'struct', 'array', +'itertools', '_socket', 'binascii', +] +} + def setup_class(cls): cls.w_connections = cls.space.newlist([]) -def socketpair(space): -"A socket.socketpair() that works on Windows" -import socket, errno -serverSocket = socket.socket() -serverSocket.bind(('127.0.0.1', 0)) -serverSocket.listen(1) +def w_socketpair(self): +"A socket.socketpair() that works on Windows" +import errno +import socket -client = socket.socket() -client.setblocking(False) -try: -client.connect(('127.0.0.1', serverSocket.getsockname()[1])) -except socket.error, e: -assert e.args[0] in (errno.EINPROGRESS, errno.EWOULDBLOCK) -server, addr = serverSocket.accept() +serverSocket = socket.socket() +serverSocket.bind(('127.0.0.1', 0)) +serverSocket.listen(1) -# keep sockets alive during the test -space.call_method(cls.w_connections, "append", space.wrap(server)) -space.call_method(cls.w_connections, "append", space.wrap(client)) +client = socket.socket() +client.setblocking(False) +try: +client.connect(('127.0.0.1', serverSocket.getsockname()[1])) +except socket.error, e: +assert e.args[0] in (errno.EINPROGRESS, errno.EWOULDBLOCK) +server, addr = serverSocket.accept() -return space.wrap((server.fileno(), client.fileno())) -if cls.runappdirect: -cls.w_socketpair = lambda self: socketpair(cls.space) -else: -cls.w_socketpair = cls.space.wrap(interp2app(socketpair)) +# keep sockets alive during the test +self.connections.append(server) +self.connections.append(client) + +return server.fileno(), client.fileno() def w_make_pair(self): import _multiprocessing -import os fd1, fd2 = self.socketpair() rhandle = _multiprocessing.Connection(fd1, writable=False) @@ -170,4 +173,3 @@ assert data1 == '\x00\x00\x00\x03abc' data2 = sock.recv(8) assert data2 == '\x00\x00\x00\x04defg' - ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: fixed select tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59268:2945718d05bc Date: 2012-12-02 15:39 -0800 http://bitbucket.org/pypy/pypy/changeset/2945718d05bc/ Log:fixed select tests diff --git a/pypy/module/select/test/test_select.py b/pypy/module/select/test/test_select.py --- a/pypy/module/select/test/test_select.py +++ b/pypy/module/select/test/test_select.py @@ -1,4 +1,9 @@ -import py, sys +import sys + +import py + +from pypy.interpreter.error import OperationError + class _AppTestSelect: def test_sleep(self): @@ -253,40 +258,44 @@ s1, s2 = os.pipe() return FileAsSocket(s1), FileAsSocket(s2) + class AppTestSelectWithSockets(_AppTestSelect): """Same tests with connected sockets. socket.socketpair() does not exists on win32, so we start our own server.""" -spaceconfig = dict(usemodules=["select", "_socket"]) +spaceconfig = { +"usemodules": ["select", "_socket", "rctime", "thread"], +} def setup_class(cls): -cls.w_getpair = cls.space.wrap(cls.getsocketpair) - -import socket -cls.sock = socket.socket() +space = cls.space +w_import = space.getattr(space.builtin, space.wrap("__import__")) +w_socketmod = space.call_function(w_import, space.wrap("socket")) +cls.w_sock = cls.space.call_method(w_socketmod, "socket") try_ports = [1023] + range(2, 3, 437) for port in try_ports: print 'binding to port %d:' % (port,), -cls.sockaddress = ('127.0.0.1', port) +cls.w_sockaddress = space.wrap(('127.0.0.1', port)) try: -cls.sock.bind(cls.sockaddress) +space.call_method(cls.w_sock, "bind", cls.w_sockaddress) print 'works' break -except socket.error, e: # should get a "Permission denied" +except OperationError, e: # should get a "Permission denied" +if not e.match(space, space.getattr(w_socketmod, space.wrap("error"))): +raise print e else: raise e -@classmethod -def getsocketpair(cls): -"""Helper method which returns a pair of connected sockets. -Note that they become faked objects at AppLevel""" -import thread, socket +def w_getpair(self): +"""Helper method which returns a pair of connected sockets.""" +import socket +import thread -cls.sock.listen(1) +self.sock.listen(1) s2 = socket.socket() -thread.start_new_thread(s2.connect, (cls.sockaddress,)) -s1, addr2 = cls.sock.accept() +thread.start_new_thread(s2.connect, (self.sockaddress,)) +s1, addr2 = self.sock.accept() return s1, s2 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: merged upstream
Author: Alex Gaynor Branch: kill-faking Changeset: r59269:041ebf6f58a7 Date: 2012-12-02 15:41 -0800 http://bitbucket.org/pypy/pypy/changeset/041ebf6f58a7/ Log:merged upstream diff --git a/pypy/module/_codecs/interp_codecs.py b/pypy/module/_codecs/interp_codecs.py --- a/pypy/module/_codecs/interp_codecs.py +++ b/pypy/module/_codecs/interp_codecs.py @@ -9,15 +9,19 @@ self.codec_search_cache = {} self.codec_error_registry = {} self.codec_need_encodings = True -self.decode_error_handler = self.make_errorhandler(space, True) -self.encode_error_handler = self.make_errorhandler(space, False) +self.decode_error_handler = self.make_decode_errorhandler(space) +self.encode_error_handler = self.make_encode_errorhandler(space) self.unicodedata_handler = None -def make_errorhandler(self, space, decode): -def unicode_call_errorhandler(errors, encoding, reason, input, - startpos, endpos): +def _make_errorhandler(self, space, decode): +def call_errorhandler(errors, encoding, reason, input, startpos, + endpos): +"""Generic wrapper for calling into error handlers. +Returns (unicode_or_none, str_or_none, newpos) as error +handlers may return unicode or on Python 3, bytes. +""" w_errorhandler = lookup_error(space, errors) if decode: w_cls = space.w_UnicodeDecodeError @@ -55,7 +59,19 @@ "position %d from error handler out of bounds", newpos) replace = space.unicode_w(w_replace) return replace, newpos -return unicode_call_errorhandler +return call_errorhandler + +def make_decode_errorhandler(self, space): +return self._make_errorhandler(space, True) + +def make_encode_errorhandler(self, space): +errorhandler = self._make_errorhandler(space, False) +def encode_call_errorhandler(errors, encoding, reason, input, startpos, + endpos): +replace, newpos = errorhandler(errors, encoding, reason, input, + startpos, endpos) +return replace, None, newpos +return encode_call_errorhandler def get_unicodedata_handler(self, space): if self.unicodedata_handler: diff --git a/pypy/module/_multibytecodec/c_codecs.py b/pypy/module/_multibytecodec/c_codecs.py --- a/pypy/module/_multibytecodec/c_codecs.py +++ b/pypy/module/_multibytecodec/c_codecs.py @@ -279,10 +279,14 @@ replace = "?" else: assert errorcb -ret, end = errorcb(errors, namecb, reason, - unicodedata, start, end) -codec = pypy_cjk_enc_getcodec(encodebuf) -replace = encode(codec, ret, "strict", errorcb, namecb) +retu, rets, end = errorcb(errors, namecb, reason, + unicodedata, start, end) +if rets is not None: +# py3k only +replace = rets +else: +codec = pypy_cjk_enc_getcodec(encodebuf) +replace = encode(codec, retu, "strict", errorcb, namecb) inbuf = rffi.get_nonmovingbuffer(replace) try: r = pypy_cjk_enc_replace_on_error(encodebuf, inbuf, len(replace), end) diff --git a/pypy/module/_multibytecodec/test/test_app_codecs.py b/pypy/module/_multibytecodec/test/test_app_codecs.py --- a/pypy/module/_multibytecodec/test/test_app_codecs.py +++ b/pypy/module/_multibytecodec/test/test_app_codecs.py @@ -102,3 +102,11 @@ repl = u"\u2014" s = u"\uDDA1".encode("gbk", "test.multi_bad_handler") assert s == '\xA1\xAA' + +def test_encode_custom_error_handler_type(self): +import codecs +import sys +codecs.register_error("test.test_encode_custom_error_handler_type", + lambda e: ('\xc3', e.end)) +raises(TypeError, u"\uDDA1".encode, "gbk", + "test.test_encode_custom_error_handler_type") diff --git a/pypy/module/_multibytecodec/test/test_c_codecs.py b/pypy/module/_multibytecodec/test/test_c_codecs.py --- a/pypy/module/_multibytecodec/test/test_c_codecs.py +++ b/pypy/module/_multibytecodec/test/test_c_codecs.py @@ -122,3 +122,10 @@ c = getcodec('iso2022_jp') s = encode(c, u'\u83ca\u5730\u6642\u592b') assert s == '\x1b$B5FCO;~IW\x1b(B' and type(s) is str + +def test_encode_custom_error_handler_bytes(): +c = getcodec("hz") +def errorhandler(errors, enc, msg, t, startingpos, endingpos): +return None, '\xc3', endingpos +s = encode(c, u'abc\u1234def', 'foo', errorhandler) +assert '\xc3' in s diff --git a/pypy/rlib/runicode.py b/pypy/rlib/runicode.py --- a/pypy/rlib/runicode.py +++ b/pypy/rlib/runicode.py @@ -57,9 +57,9 @@ def default_unicode_error_encode(errors, encoding, msg, u,
[pypy-commit] pypy py3k: merge default
Author: Philip Jenvey Branch: py3k Changeset: r59270:b85a52c00034 Date: 2012-12-02 14:45 -0800 http://bitbucket.org/pypy/pypy/changeset/b85a52c00034/ Log:merge default diff --git a/pypy/module/_codecs/interp_codecs.py b/pypy/module/_codecs/interp_codecs.py --- a/pypy/module/_codecs/interp_codecs.py +++ b/pypy/module/_codecs/interp_codecs.py @@ -9,15 +9,19 @@ self.codec_search_cache = {} self.codec_error_registry = {} self.codec_need_encodings = True -self.decode_error_handler = self.make_errorhandler(space, True) -self.encode_error_handler = self.make_errorhandler(space, False) +self.decode_error_handler = self.make_decode_errorhandler(space) +self.encode_error_handler = self.make_encode_errorhandler(space) self.unicodedata_handler = None -def make_errorhandler(self, space, decode): -def unicode_call_errorhandler(errors, encoding, reason, input, - startpos, endpos): +def _make_errorhandler(self, space, decode): +def call_errorhandler(errors, encoding, reason, input, startpos, + endpos): +"""Generic wrapper for calling into error handlers. +Returns (unicode_or_none, str_or_none, newpos) as error +handlers may return unicode or on Python 3, bytes. +""" w_errorhandler = lookup_error(space, errors) if decode: w_cls = space.w_UnicodeDecodeError @@ -56,16 +60,21 @@ raise operationerrfmt( space.w_IndexError, "position %d from error handler out of bounds", newpos) -if decode: -replace = space.unicode_w(w_replace) -return replace, newpos -else: -from pypy.objspace.std.unicodetype import encode_object -if space.isinstance_w(w_replace, space.w_unicode): -w_replace = encode_object(space, w_replace, encoding, None) -replace = space.bytes_w(w_replace) -return replace, newpos -return unicode_call_errorhandler +replace = space.unicode_w(w_replace) +return replace, newpos +return call_errorhandler + +def make_decode_errorhandler(self, space): +return self._make_errorhandler(space, True) + +def make_encode_errorhandler(self, space): +errorhandler = self._make_errorhandler(space, False) +def encode_call_errorhandler(errors, encoding, reason, input, startpos, + endpos): +replace, newpos = errorhandler(errors, encoding, reason, input, + startpos, endpos) +return replace, None, newpos +return encode_call_errorhandler def get_unicodedata_handler(self, space): if self.unicodedata_handler: diff --git a/pypy/module/_codecs/test/test_codecs.py b/pypy/module/_codecs/test/test_codecs.py --- a/pypy/module/_codecs/test/test_codecs.py +++ b/pypy/module/_codecs/test/test_codecs.py @@ -2,7 +2,7 @@ class AppTestCodecs: -spaceconfig = dict(usemodules=('unicodedata', 'struct')) +spaceconfig = dict(usemodules=('binascii', 'struct', 'unicodedata')) def test_register_noncallable(self): import _codecs diff --git a/pypy/module/_multibytecodec/c_codecs.py b/pypy/module/_multibytecodec/c_codecs.py --- a/pypy/module/_multibytecodec/c_codecs.py +++ b/pypy/module/_multibytecodec/c_codecs.py @@ -279,8 +279,14 @@ replace = "?" else: assert errorcb -replace, end = errorcb(errors, namecb, reason, - unicodedata, start, end) +retu, rets, end = errorcb(errors, namecb, reason, + unicodedata, start, end) +if rets is not None: +# py3k only +replace = rets +else: +codec = pypy_cjk_enc_getcodec(encodebuf) +replace = encode(codec, retu, "strict", errorcb, namecb) inbuf = rffi.get_nonmovingbuffer(replace) try: r = pypy_cjk_enc_replace_on_error(encodebuf, inbuf, len(replace), end) diff --git a/pypy/module/_multibytecodec/test/test_app_codecs.py b/pypy/module/_multibytecodec/test/test_app_codecs.py --- a/pypy/module/_multibytecodec/test/test_app_codecs.py +++ b/pypy/module/_multibytecodec/test/test_app_codecs.py @@ -102,3 +102,11 @@ repl = "\u2014" s = "\uDDA1".encode("gbk", "test.multi_bad_handler") assert s == b'\xA1\xAA' + +def test_encode_custom_error_handler_type(self): +import codecs +import sys +codecs.register_error("test.test_encode_custom_error_handler_type", + lambda e: ('\xc3', e.end)) +raises(TypeError, u"\uDDA1".encode, "gbk", + "test.test_encode_custom_error_handler_type") diff --git
[pypy-commit] pypy py3k: merge
Author: Philip Jenvey Branch: py3k Changeset: r59271:078592628907 Date: 2012-12-02 15:14 -0800 http://bitbucket.org/pypy/pypy/changeset/078592628907/ Log:merge diff --git a/lib_pypy/_testcapimodule.c b/lib_pypy/_testcapimodule.c --- a/lib_pypy/_testcapimodule.c +++ b/lib_pypy/_testcapimodule.c @@ -1,5 +1,4 @@ -/* Verbatim copy of Modules/_testcapimodule.c from CPython 3.2 w/ use - of PyInstanceMethod disabled */ +/* Verbatim copy of Modules/_testcapimodule.c from CPython 3.2 */ /* * C Extension module to test Python interpreter C APIs. * @@ -2626,10 +2625,8 @@ PyModule_AddObject(m, "PY_SSIZE_T_MAX", PyLong_FromSsize_t(PY_SSIZE_T_MAX)); PyModule_AddObject(m, "PY_SSIZE_T_MIN", PyLong_FromSsize_t(PY_SSIZE_T_MIN)); PyModule_AddObject(m, "SIZEOF_PYGC_HEAD", PyLong_FromSsize_t(sizeof(PyGC_Head))); -#if 0 /* XXX: disabled for PyPy (for now) */ Py_INCREF(&PyInstanceMethod_Type); PyModule_AddObject(m, "instancemethod", (PyObject *)&PyInstanceMethod_Type); -#endif TestError = PyErr_NewException("_testcapi.error", NULL, NULL); Py_INCREF(TestError); diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py --- a/pypy/module/cpyext/api.py +++ b/pypy/module/cpyext/api.py @@ -650,8 +650,12 @@ lambda space: init_capsule(), ]) from pypy.module.posix.interp_posix import add_fork_hook -reinit_tls = rffi.llexternal('PyThread_ReInitTLS', [], lltype.Void, - compilation_info=eci) +if we_are_translated(): +reinit_tls = rffi.llexternal('PyThread_ReInitTLS', [], lltype.Void, + compilation_info=eci) +else: +reinit_tls = rffi.llexternal('PyPyThread_ReInitTLS', [], lltype.Void, + compilation_info=eci) add_fork_hook('child', reinit_tls) def init_function(func): diff --git a/pypy/module/cpyext/buffer.py b/pypy/module/cpyext/buffer.py --- a/pypy/module/cpyext/buffer.py +++ b/pypy/module/cpyext/buffer.py @@ -1,8 +1,8 @@ -from pypy.interpreter.error import OperationError from pypy.rpython.lltypesystem import rffi, lltype from pypy.module.cpyext.api import ( cpython_api, CANNOT_FAIL, Py_buffer) -from pypy.module.cpyext.pyobject import PyObject +from pypy.module.cpyext.pyobject import PyObject, Py_DecRef +from pypy.interpreter import buffer @cpython_api([lltype.Ptr(Py_buffer), lltype.Char], rffi.INT_real, error=CANNOT_FAIL) def PyBuffer_IsContiguous(space, view, fortran): @@ -11,3 +11,27 @@ (fortran is 'A'). Return 0 otherwise.""" # PyPy only supports contiguous Py_buffers for now. return 1 + +class CBufferMixin(object): +_mixin_ = True + +def __init__(self, space, c_buf, c_len, w_obj): +self.space = space +self.c_buf = c_buf +self.c_len = c_len +self.w_obj = w_obj + +def __del__(self): +Py_DecRef(self.space, self.w_obj) + +def getlength(self): +return self.c_len + +def getitem(self, index): +return self.c_buf[index] + +def as_str(self): +return rffi.charpsize2str(self.c_buf, self.c_len) + +class CBuffer(CBufferMixin, buffer.Buffer): +pass diff --git a/pypy/module/cpyext/memoryobject.py b/pypy/module/cpyext/memoryobject.py --- a/pypy/module/cpyext/memoryobject.py +++ b/pypy/module/cpyext/memoryobject.py @@ -1,6 +1,19 @@ -from pypy.module.cpyext.api import cpython_api -from pypy.module.cpyext.pyobject import PyObject +from pypy.module.cpyext.api import cpython_api, Py_buffer +from pypy.module.cpyext.pyobject import PyObject, from_ref +from pypy.module.cpyext.buffer import CBuffer +from pypy.rpython.lltypesystem import rffi, lltype +from pypy.module.__builtin__.interp_memoryview import W_MemoryView @cpython_api([PyObject], PyObject) def PyMemoryView_FromObject(space, w_obj): return space.call_method(space.builtin, "memoryview", w_obj) + +@cpython_api([lltype.Ptr(Py_buffer)], PyObject) +def PyMemoryView_FromBuffer(space, view): +"""Create a memoryview object wrapping the given buffer structure view. +The memoryview object then owns the buffer represented by view, which +means you shouldn't try to call PyBuffer_Release() yourself: it +will be done on deallocation of the memoryview object.""" +w_obj = from_ref(space, view.c_obj) +buf = CBuffer(space, view.c_buf, view.c_len, w_obj) +return space.wrap(W_MemoryView(space.wrap(buf))) diff --git a/pypy/module/cpyext/stubs.py b/pypy/module/cpyext/stubs.py --- a/pypy/module/cpyext/stubs.py +++ b/pypy/module/cpyext/stubs.py @@ -1610,15 +1610,6 @@ raise NotImplementedError -@cpython_api([Py_buffer], PyObject) -def PyMemoryView_FromBuffer(space, view): -"""Create a memoryview object wrapping the given buffer structure view. -The memoryview object then owns the buffer represented by view, which -means you shouldn't try to call PyBuffer_Release() yourself: it -will be done on deallocation of th
[pypy-commit] pypy py3k: adapt 66eb9aa93bb4 to py3k, fixes some cases of surrogateescape failing. as an
Author: Philip Jenvey Branch: py3k Changeset: r59272:fcd9446ab85f Date: 2012-12-02 15:16 -0800 http://bitbucket.org/pypy/pypy/changeset/fcd9446ab85f/ Log:adapt 66eb9aa93bb4 to py3k, fixes some cases of surrogateescape failing. as an aside, this finishes syncing runicode.py between the branches diff --git a/pypy/module/_codecs/interp_codecs.py b/pypy/module/_codecs/interp_codecs.py --- a/pypy/module/_codecs/interp_codecs.py +++ b/pypy/module/_codecs/interp_codecs.py @@ -60,20 +60,27 @@ raise operationerrfmt( space.w_IndexError, "position %d from error handler out of bounds", newpos) -replace = space.unicode_w(w_replace) -return replace, newpos +return w_replace, newpos return call_errorhandler def make_decode_errorhandler(self, space): -return self._make_errorhandler(space, True) +errorhandler = self._make_errorhandler(space, True) +def decode_call_errorhandler(errors, encoding, reason, input, + startpos, endpos): +w_replace, newpos = errorhandler(errors, encoding, reason, input, + startpos, endpos) +return space.unicode_w(w_replace), newpos +return decode_call_errorhandler def make_encode_errorhandler(self, space): errorhandler = self._make_errorhandler(space, False) -def encode_call_errorhandler(errors, encoding, reason, input, startpos, - endpos): -replace, newpos = errorhandler(errors, encoding, reason, input, - startpos, endpos) -return replace, None, newpos +def encode_call_errorhandler(errors, encoding, reason, input, + startpos, endpos): +w_replace, newpos = errorhandler(errors, encoding, reason, input, + startpos, endpos) +if space.isinstance_w(w_replace, space.w_unicode): +return space.unicode_w(w_replace), None, newpos +return None, space.bytes_w(w_replace), newpos return encode_call_errorhandler def get_unicodedata_handler(self, space): diff --git a/pypy/module/_multibytecodec/test/test_app_codecs.py b/pypy/module/_multibytecodec/test/test_app_codecs.py --- a/pypy/module/_multibytecodec/test/test_app_codecs.py +++ b/pypy/module/_multibytecodec/test/test_app_codecs.py @@ -108,5 +108,5 @@ import sys codecs.register_error("test.test_encode_custom_error_handler_type", lambda e: ('\xc3', e.end)) -raises(TypeError, u"\uDDA1".encode, "gbk", - "test.test_encode_custom_error_handler_type") +result = "\uDDA1".encode("gbk", "test.test_encode_custom_error_handler_type") +assert '\xc3' in result ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: ensure surrogateescape is fixed, add another encoding related test and fix
Author: Philip Jenvey Branch: py3k Changeset: r59273:612464ae843f Date: 2012-12-02 15:39 -0800 http://bitbucket.org/pypy/pypy/changeset/612464ae843f/ Log:ensure surrogateescape is fixed, add another encoding related test and fix diff --git a/pypy/module/_codecs/test/test_codecs.py b/pypy/module/_codecs/test/test_codecs.py --- a/pypy/module/_codecs/test/test_codecs.py +++ b/pypy/module/_codecs/test/test_codecs.py @@ -485,6 +485,8 @@ def test_surrogateescape(self): assert b'a\x80b'.decode('utf-8', 'surrogateescape') == 'a\udc80b' assert 'a\udc80b'.encode('utf-8', 'surrogateescape') == b'a\x80b' +for enc in ('utf-8', 'ascii', 'latin-1', 'charmap'): +assert '\udcc3'.encode(enc, 'surrogateescape') == b'\xc3' def test_surrogatepass_handler(self): import _codecs diff --git a/pypy/module/_multibytecodec/test/test_app_codecs.py b/pypy/module/_multibytecodec/test/test_app_codecs.py --- a/pypy/module/_multibytecodec/test/test_app_codecs.py +++ b/pypy/module/_multibytecodec/test/test_app_codecs.py @@ -63,6 +63,14 @@ raises((IndexError, OverflowError), b"abc\xDD".decode, "hz", "test.test_decode_custom_error_handler_overflow") +def test_decode_custom_error_handler_type(self): +import codecs +import sys +codecs.register_error("test.test_decode_custom_error_handler_type", + lambda e: (b'', e.end)) +raises(TypeError, b"abc\xDD".decode, "hz", + "test.test_decode_custom_error_handler_type") + def test_encode_hz(self): import _codecs_cn codec = _codecs_cn.getcodec("hz") @@ -107,6 +115,6 @@ import codecs import sys codecs.register_error("test.test_encode_custom_error_handler_type", - lambda e: ('\xc3', e.end)) + lambda e: (b'\xc3', e.end)) result = "\uDDA1".encode("gbk", "test.test_encode_custom_error_handler_type") -assert '\xc3' in result +assert b'\xc3' in result ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: Fixed test_pwd tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59274:2d86c824b8ad Date: 2012-12-03 00:48 +0100 http://bitbucket.org/pypy/pypy/changeset/2d86c824b8ad/ Log:Fixed test_pwd tests diff --git a/pypy/module/test_lib_pypy/test_pwd.py b/pypy/module/test_lib_pypy/test_pwd.py --- a/pypy/module/test_lib_pypy/test_pwd.py +++ b/pypy/module/test_lib_pypy/test_pwd.py @@ -1,7 +1,7 @@ import py, sys class AppTestPwd: -spaceconfig = dict(usemodules=('_ffi', '_rawffi', 'itertools')) +spaceconfig = dict(usemodules=('_ffi', '_rawffi', 'itertools', 'binascii')) def setup_class(cls): if sys.platform == 'win32': ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix codewriter tests
Author: Alex Gaynor Branch: Changeset: r59275:b32f5b91169d Date: 2012-12-02 15:56 -0800 http://bitbucket.org/pypy/pypy/changeset/b32f5b91169d/ Log:fix codewriter tests diff --git a/pypy/jit/codewriter/test/test_codewriter.py b/pypy/jit/codewriter/test/test_codewriter.py --- a/pypy/jit/codewriter/test/test_codewriter.py +++ b/pypy/jit/codewriter/test/test_codewriter.py @@ -1,8 +1,11 @@ import py + +from pypy.jit.codewriter import support from pypy.jit.codewriter.codewriter import CodeWriter -from pypy.jit.codewriter import support from pypy.jit.metainterp.history import AbstractDescr from pypy.rpython.lltypesystem import lltype, llmemory, rffi +from pypy.translator.backendopt.all import backend_optimizations + class FakeCallDescr(AbstractDescr): def __init__(self, FUNC, ARGS, RESULT, effectinfo): @@ -230,7 +233,8 @@ rtyper = support.annotate(f, [-1]) jitdriver_sd = FakeJitDriverSD(rtyper.annotator.translator.graphs[0]) cw = CodeWriter(FakeCPU(rtyper), [jitdriver_sd]) -cw.find_all_graphs(FakePolicy()) +graphs = cw.find_all_graphs(FakePolicy()) +backend_optimizations(rtyper.annotator.translator, graphs=graphs) cw.make_jitcodes(verbose=True) s = jitdriver_sd.mainjitcode.dump() assert 'int_force_ge_zero' in s ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: merged in default
Author: Alex Gaynor Branch: kill-faking Changeset: r59276:592aa4d70098 Date: 2012-12-02 15:57 -0800 http://bitbucket.org/pypy/pypy/changeset/592aa4d70098/ Log:merged in default diff --git a/pypy/jit/codewriter/test/test_codewriter.py b/pypy/jit/codewriter/test/test_codewriter.py --- a/pypy/jit/codewriter/test/test_codewriter.py +++ b/pypy/jit/codewriter/test/test_codewriter.py @@ -1,8 +1,11 @@ import py + +from pypy.jit.codewriter import support from pypy.jit.codewriter.codewriter import CodeWriter -from pypy.jit.codewriter import support from pypy.jit.metainterp.history import AbstractDescr from pypy.rpython.lltypesystem import lltype, llmemory, rffi +from pypy.translator.backendopt.all import backend_optimizations + class FakeCallDescr(AbstractDescr): def __init__(self, FUNC, ARGS, RESULT, effectinfo): @@ -230,7 +233,8 @@ rtyper = support.annotate(f, [-1]) jitdriver_sd = FakeJitDriverSD(rtyper.annotator.translator.graphs[0]) cw = CodeWriter(FakeCPU(rtyper), [jitdriver_sd]) -cw.find_all_graphs(FakePolicy()) +graphs = cw.find_all_graphs(FakePolicy()) +backend_optimizations(rtyper.annotator.translator, graphs=graphs) cw.make_jitcodes(verbose=True) s = jitdriver_sd.mainjitcode.dump() assert 'int_force_ge_zero' in s ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: Fix translation
Author: Amaury Forgeot d'Arc Branch: py3k Changeset: r59277:6dd3cc751054 Date: 2012-12-03 00:57 +0100 http://bitbucket.org/pypy/pypy/changeset/6dd3cc751054/ Log:Fix translation diff --git a/pypy/module/cpyext/buffer.py b/pypy/module/cpyext/buffer.py --- a/pypy/module/cpyext/buffer.py +++ b/pypy/module/cpyext/buffer.py @@ -21,7 +21,8 @@ self.c_len = c_len self.w_obj = w_obj -def __del__(self): +def destructor(self): +assert isinstance(self, CBufferMixin) Py_DecRef(self.space, self.w_obj) def getlength(self): @@ -31,7 +32,10 @@ return self.c_buf[index] def as_str(self): -return rffi.charpsize2str(self.c_buf, self.c_len) +return rffi.charpsize2str(rffi.cast(rffi.CCHARP, self.c_buf), + self.c_len) class CBuffer(CBufferMixin, buffer.Buffer): -pass +def __del__(self): +self.enqueue_for_destruction(self.space, CBufferMixin.destructor, + 'internal __del__ of ') ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: merged default
Author: Alex Gaynor Branch: kill-faking Changeset: r59279:e10febbbcd71 Date: 2012-12-02 15:58 -0800 http://bitbucket.org/pypy/pypy/changeset/e10febbbcd71/ Log:merged default diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -7,10 +7,13 @@ .. branch: length-hint Implement __lenght_hint__ according to PEP 424 - + .. branches we don't care about .. branch: autoreds .. branch: release-2.0-beta1 .. branch: remove-PYPY_NOT_MAIN_FILE + +.. branch: fix-lookinside-iff-oopspec +Fixed the interaction between two internal tools for controlling the JIT. ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Documented fix-lookinside-iff-oopspec
Author: Alex Gaynor Branch: Changeset: r59278:70ae9ffd470e Date: 2012-12-02 15:58 -0800 http://bitbucket.org/pypy/pypy/changeset/70ae9ffd470e/ Log:Documented fix-lookinside-iff-oopspec diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -7,10 +7,13 @@ .. branch: length-hint Implement __lenght_hint__ according to PEP 424 - + .. branches we don't care about .. branch: autoreds .. branch: release-2.0-beta1 .. branch: remove-PYPY_NOT_MAIN_FILE + +.. branch: fix-lookinside-iff-oopspec +Fixed the interaction between two internal tools for controlling the JIT. ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: a bit of progress on teh math tests
Author: Alex Gaynor Branch: kill-faking Changeset: r59280:515611fa6e51 Date: 2012-12-02 16:15 -0800 http://bitbucket.org/pypy/pypy/changeset/515611fa6e51/ Log:a bit of progress on teh math tests diff --git a/pypy/module/math/test/test_math.py b/pypy/module/math/test/test_math.py --- a/pypy/module/math/test/test_math.py +++ b/pypy/module/math/test/test_math.py @@ -1,5 +1,5 @@ from __future__ import with_statement -import sys + from pypy.module.math.test import test_direct @@ -7,8 +7,16 @@ spaceconfig = dict(usemodules=['math', 'struct', 'itertools']) def setup_class(cls): -cls.w_cases = cls.space.wrap(test_direct.MathTests.TESTCASES) -cls.w_consistent_host = cls.space.wrap(test_direct.consistent_host) +space = cls.space +cases = [] +for a, b, expected in test_direct.MathTests.TESTCASES: +if type(expected) is type and issubclass(expected, Exception): +expected = getattr(space, "w_%s" % expected.__name__) +else: +expected = space.wrap(expected) +cases.append(space.newtuple([space.wrap(a), space.wrap(b), expected])) +cls.w_cases = space.newlist(cases) +cls.w_consistent_host = space.wrap(test_direct.consistent_host) def w_ftest(self, actual, expected): assert abs(actual - expected) < 10E-5 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: Fixed _hashlib, _md5, and _sha tests.
Author: Alex Gaynor Branch: kill-faking Changeset: r59281:5a39ec9e6538 Date: 2012-12-02 16:53 -0800 http://bitbucket.org/pypy/pypy/changeset/5a39ec9e6538/ Log:Fixed _hashlib, _md5, and _sha tests. diff --git a/pypy/module/_hashlib/test/test_hashlib.py b/pypy/module/_hashlib/test/test_hashlib.py --- a/pypy/module/_hashlib/test/test_hashlib.py +++ b/pypy/module/_hashlib/test/test_hashlib.py @@ -1,7 +1,7 @@ -import py - class AppTestHashlib: -spaceconfig = dict(usemodules=['_hashlib', 'array', 'struct']) +spaceconfig = { +"usemodules": ['_hashlib', 'array', 'struct', 'binascii'], +} def test_simple(self): import _hashlib diff --git a/pypy/module/_md5/test/test_md5.py b/pypy/module/_md5/test/test_md5.py --- a/pypy/module/_md5/test/test_md5.py +++ b/pypy/module/_md5/test/test_md5.py @@ -5,7 +5,7 @@ class AppTestMD5(object): spaceconfig = { -"usemodules": ['_md5', 'rctime'], +"usemodules": ['_md5', 'rctime', 'binascii'], } def setup_class(cls): @@ -26,7 +26,6 @@ assert self.md5.blocksize == 1 assert self.md5.md5().digestsize == 16 - def test_MD5Type(self): """ Test the two ways to construct an md5 object. @@ -39,7 +38,6 @@ d = md5.new() assert isinstance(d, md5.MD5Type) - def test_md5object(self): """ Feed example strings into a md5 object and check the digest and @@ -59,7 +57,7 @@ "c3fcd3d76192e4007dfb496cca67e13b"), ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "d174ab98d277d9f5a5611c2c9f419d9f"), - ("1234567890"*8, + ("1234567890" * 8, "57edf4a22be3c955ac49da2e2107b67a"), ) for input, expected in cases: @@ -67,7 +65,6 @@ assert d.hexdigest() == expected assert d.digest() == expected.decode('hex') - def test_copy(self): """ Test the copy() method. @@ -81,7 +78,6 @@ assert d1.hexdigest() == 'e570e7110ecef72fcb772a9c05d03373' assert d2.hexdigest() == 'e8dc4081b13434b45189a720b77b6818' - def test_buffer(self): """ Test passing a buffer object. @@ -91,7 +87,6 @@ d1.update(buffer("jkl")) assert d1.hexdigest() == 'e570e7110ecef72fcb772a9c05d03373' - def test_unicode(self): """ Test passing unicode strings. diff --git a/pypy/module/_sha/test/test_sha.py b/pypy/module/_sha/test/test_sha.py --- a/pypy/module/_sha/test/test_sha.py +++ b/pypy/module/_sha/test/test_sha.py @@ -5,7 +5,7 @@ class AppTestSHA(object): spaceconfig = { -"usemodules": ['_sha', 'rctime'], +"usemodules": ['_sha', 'rctime', 'binascii'], } def setup_class(cls): @@ -25,7 +25,6 @@ assert d.digest_size == 20 assert d.digestsize == 20 - def test_SHAType(self): """ Test the two ways to construct an sha object. @@ -38,7 +37,6 @@ d = sha.new() assert isinstance(d, sha.SHAType) - def test_shaobject(self): """ Feed example strings into a sha object and check the digest and @@ -56,7 +54,7 @@ "c12252ceda8be8994d5fa0290a47231c1d16aae3"), ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "761c457bf73b14d27e9e9265c46f4b4dda11f940"), - ("1234567890"*8, + ("1234567890" * 8, "50abf5706a150990a08b2c5ea40fa0e585554732"), ("1234567890"*999, "eaaca5490568fde98d8dc553d9566bdc602fde4a"), @@ -66,7 +64,6 @@ assert d.hexdigest() == expected assert d.digest() == expected.decode('hex') - def test_copy(self): """ Test the copy() method. @@ -80,7 +77,6 @@ assert d1.hexdigest() == 'f5d13cf6341db9b0e299d7b9d562de9572b58e5d' assert d2.hexdigest() == '425af12a0743502b322e93a015bcf868e324d56a' - def test_buffer(self): """ Test passing a buffer object. @@ -90,7 +86,6 @@ d1.update(buffer("jkl")) assert d1.hexdigest() == 'f5d13cf6341db9b0e299d7b9d562de9572b58e5d' - def test_unicode(self): """ Test passing unicode strings. ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: get the rest of math tests passing
Author: Alex Gaynor Branch: kill-faking Changeset: r59282:a18b9026eeca Date: 2012-12-02 17:13 -0800 http://bitbucket.org/pypy/pypy/changeset/a18b9026eeca/ Log:get the rest of math tests passing diff --git a/pypy/module/math/test/test_math.py b/pypy/module/math/test/test_math.py --- a/pypy/module/math/test/test_math.py +++ b/pypy/module/math/test/test_math.py @@ -1,10 +1,14 @@ from __future__ import with_statement +from pypy.interpreter.function import Function +from pypy.interpreter.gateway import BuiltinCode from pypy.module.math.test import test_direct class AppTestMath: -spaceconfig = dict(usemodules=['math', 'struct', 'itertools']) +spaceconfig = { +"usemodules": ['math', 'struct', 'itertools', 'rctime', 'binascii'], +} def setup_class(cls): space = cls.space @@ -12,12 +16,20 @@ for a, b, expected in test_direct.MathTests.TESTCASES: if type(expected) is type and issubclass(expected, Exception): expected = getattr(space, "w_%s" % expected.__name__) +elif callable(expected): +expected = cls.make_callable_wrapper(expected) else: expected = space.wrap(expected) cases.append(space.newtuple([space.wrap(a), space.wrap(b), expected])) cls.w_cases = space.newlist(cases) cls.w_consistent_host = space.wrap(test_direct.consistent_host) +@classmethod +def make_callable_wrapper(cls, func): +def f(space, w_x): +return space.wrap(func(space.unwrap(w_x))) +return Function(cls.space, BuiltinCode(f)) + def w_ftest(self, actual, expected): assert abs(actual - expected) < 10E-5 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: kill some left over faking stuff
Author: Alex Gaynor Branch: kill-faking Changeset: r59283:df0d942ac4a6 Date: 2012-12-02 17:17 -0800 http://bitbucket.org/pypy/pypy/changeset/df0d942ac4a6/ Log:kill some left over faking stuff diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py --- a/pypy/interpreter/baseobjspace.py +++ b/pypy/interpreter/baseobjspace.py @@ -509,15 +509,10 @@ for name, w_type in types_w: self.setitem(self.builtin.w_dict, self.wrap(name), w_type) -# install mixed and faked modules +# install mixed modules for mixedname in self.get_builtinmodule_to_install(): -if (mixedname not in bootstrap_modules -and not mixedname.startswith('faked+')): +if mixedname not in bootstrap_modules: self.install_mixedmodule(mixedname, installed_builtin_modules) -for mixedname in self.get_builtinmodule_to_install(): -if mixedname.startswith('faked+'): -modname = mixedname[6:] -self.install_faked_module(modname, installed_builtin_modules) installed_builtin_modules.sort() w_builtin_module_names = self.newtuple( @@ -560,19 +555,6 @@ cpy_module = __import__(modname, {}, {}, ['*']) return cpy_module -def install_faked_module(self, modname, installed_builtin_modules): -"""NOT_RPYTHON""" -if modname in installed_builtin_modules: -return -try: -module = self.load_cpython_module(modname) -except ImportError: -return -else: -w_modules = self.sys.get('modules') -self.setitem(w_modules, self.wrap(modname), self.wrap(module)) -installed_builtin_modules.append(modname) - def setup_builtin_modules(self): "NOT_RPYTHON: only for initializing the space." if self.config.objspace.usemodules.cpyext: diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py --- a/pypy/interpreter/typedef.py +++ b/pypy/interpreter/typedef.py @@ -32,8 +32,6 @@ self.rawdict = {} self.acceptable_as_base_class = '__new__' in rawdict self.applevel_subclasses_base = None -# xxx used by faking -self.fakedcpytype = None self.add_entries(**rawdict) assert __total_ordering__ in (None, 'auto'), "Unknown value for __total_ordering" if __total_ordering__ == 'auto': diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py --- a/pypy/objspace/std/typeobject.py +++ b/pypy/objspace/std/typeobject.py @@ -469,8 +469,6 @@ return W_DictMultiObject(space, strategy, storage) def unwrap(w_self, space): -if w_self.instancetypedef.fakedcpytype is not None: -return w_self.instancetypedef.fakedcpytype from pypy.objspace.std.model import UnwrapError raise UnwrapError(w_self) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: kill one more thing
Author: Alex Gaynor Branch: kill-faking Changeset: r59284:a3c1f53d4087 Date: 2012-12-02 17:18 -0800 http://bitbucket.org/pypy/pypy/changeset/a3c1f53d4087/ Log:kill one more thing diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py --- a/pypy/interpreter/baseobjspace.py +++ b/pypy/interpreter/baseobjspace.py @@ -550,11 +550,6 @@ "app-level module %r" % (modname,)) installed_builtin_modules.append(modname) -def load_cpython_module(self, modname): -"NOT_RPYTHON. Steal a module from CPython." -cpy_module = __import__(modname, {}, {}, ['*']) -return cpy_module - def setup_builtin_modules(self): "NOT_RPYTHON: only for initializing the space." if self.config.objspace.usemodules.cpyext: ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy kill-faking: make this comment more accurate
Author: Alex Gaynor Branch: kill-faking Changeset: r59285:4053bfea30e2 Date: 2012-12-02 17:23 -0800 http://bitbucket.org/pypy/pypy/changeset/4053bfea30e2/ Log:make this comment more accurate diff --git a/pypy/interpreter/pycode.py b/pypy/interpreter/pycode.py --- a/pypy/interpreter/pycode.py +++ b/pypy/interpreter/pycode.py @@ -153,10 +153,8 @@ @classmethod def _from_code(cls, space, code, hidden_applevel=False, code_hook=None): -""" Initialize the code object from a real (CPython) one. -This is just a hack, until we have our own compile. -At the moment, we just fake this. -This method is called by our compile builtin function. +""" +Hack to initialize the code object from a real (CPython) one. """ assert isinstance(code, types.CodeType) newconsts_w = [None] * len(code.co_consts) @@ -186,7 +184,6 @@ list(code.co_cellvars), hidden_applevel, cpython_magic) - def _compute_flatcall(self): # Speed hack! self.fast_natural_arity = eval.Code.HOPELESS ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-globals-in-jit: Bah, it's actually never None.
Author: Armin Rigo Branch: remove-globals-in-jit Changeset: r59286:fc72fed04f5b Date: 2012-12-02 18:01 -0800 http://bitbucket.org/pypy/pypy/changeset/fc72fed04f5b/ Log:Bah, it's actually never None. diff --git a/pypy/jit/metainterp/resume.py b/pypy/jit/metainterp/resume.py --- a/pypy/jit/metainterp/resume.py +++ b/pypy/jit/metainterp/resume.py @@ -1085,9 +1085,6 @@ def consume_virtualref_info(self, vrefinfo, numb, end): # we have to decode a list of references containing pairs # [..., virtual, vref, ...] stopping at 'end' -if vrefinfo is None: -assert end == 0 -return assert (end & 1) == 0 for i in range(0, end, 2): virtual = self.decode_ref(numb.nums[i]) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-globals-in-jit: Trying it out now: re-enable the JIT with continulets
Author: Armin Rigo Branch: remove-globals-in-jit Changeset: r59288:4ed15aefc3f0 Date: 2012-12-02 18:14 -0800 http://bitbucket.org/pypy/pypy/changeset/4ed15aefc3f0/ Log:Trying it out now: re-enable the JIT with continulets diff --git a/pypy/module/_continuation/interp_continuation.py b/pypy/module/_continuation/interp_continuation.py --- a/pypy/module/_continuation/interp_continuation.py +++ b/pypy/module/_continuation/interp_continuation.py @@ -34,7 +34,6 @@ if self.sthread is not None: raise geterror(self.space, "continulet already __init__ialized") sthread = build_sthread(self.space) -workaround_disable_jit(sthread) # # hackish: build the frame "by hand", passing it the correct arguments space = self.space @@ -77,7 +76,6 @@ global_state.clear() raise geterror(self.space, "continulet already finished") self.check_sthread() -workaround_disable_jit(self.sthread) # global_state.origin = self if to is None: @@ -271,16 +269,6 @@ sthread = ec.stacklet_thread = SThread(space, ec) return sthread -def workaround_disable_jit(sthread): -# A bad workaround to kill the JIT anywhere in this thread. -# This forces all the frames. It's a bad workaround because -# it takes O(depth) time, and it will cause some "abort: -# vable escape" in the JIT. The goal is to prevent any frame -# from being still virtuals, because the JIT generates code -# to un-virtualizable them "on demand" by loading values based -# on FORCE_TOKEN, which is an address in the stack. -sthread.ec.force_all_frames() - # def permute(space, args_w): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit