[pypy-commit] lang-js default: cleaned up comparsion code
Author: Stephan Branch: Changeset: r377:fb52d8a52d9e Date: 2013-05-13 09:11 +0200 http://bitbucket.org/pypy/lang-js/changeset/fb52d8a52d9e/ Log:cleaned up comparsion code diff --git a/js/baseop.py b/js/baseop.py --- a/js/baseop.py +++ b/js/baseop.py @@ -3,10 +3,12 @@ """ from js.jsobj import W_String, W_IntNumber, W_FloatNumber -from js.object_space import _w, isint +from js.object_space import _w, isint, isstr, isfloat from rpython.rlib.rarithmetic import ovfcheck from rpython.rlib.rfloat import isnan, isinf +from rpython.rlib.objectmodel import specialize + from js.builtins.number import w_NAN, w_POSITIVE_INFINITY, w_NEGATIVE_INFINITY import math @@ -141,50 +143,56 @@ return W_FloatNumber(val) -def compare(ctx, x, y): +@specialize.argtype(0, 1) +def _compare_gt(x, y): +return x > y + + +@specialize.argtype(0, 1) +def _compare_ge(x, y): +return x >= y + + +def _base_compare(x, y, _compare): if isint(x) and isint(y): -return x.ToInteger() > y.ToInteger() -if isinstance(x, W_FloatNumber) and isinstance(y, W_FloatNumber): -if isnan(x.ToNumber()) or isnan(y.ToNumber()): -return -1 -return x.ToNumber() > y.ToNumber() -s1 = x.ToPrimitive('Number') -s2 = y.ToPrimitive('Number') -if not (isinstance(s1, W_String) and isinstance(s2, W_String)): -s4 = s1.ToNumber() -s5 = s2.ToNumber() -if isnan(s4) or isnan(s5): -return False -return s4 > s5 +return _compare(x.ToInteger(), y.ToInteger()) + +if isfloat(x) and isfloat(y): +n1 = x.ToNumber() +n2 = x.ToNumber() +return _compare(n1, n2) + +p1 = x.ToPrimitive('Number') +p2 = y.ToPrimitive('Number') + +if not (isstr(p1) and isstr(p2)): +n1 = p1.ToNumber() +n2 = p2.ToNumber() +return _compare(n1, n2) else: -s4 = s1.to_string() -s5 = s2.to_string() -return s4 > s5 +s1 = p1.to_string() +s2 = p2.to_string() +return _compare(s1, s2) -def compare_e(ctx, x, y): -if isint(x) and isint(y): -return x.ToInteger() >= y.ToInteger() -if isinstance(x, W_FloatNumber) and isinstance(y, W_FloatNumber): -if isnan(x.ToNumber()) or isnan(y.ToNumber()): -return -1 -return x.ToNumber() >= y.ToNumber() -s1 = x.ToPrimitive('Number') -s2 = y.ToPrimitive('Number') -if not (isinstance(s1, W_String) and isinstance(s2, W_String)): -s4 = s1.ToNumber() -s5 = s2.ToNumber() -if isnan(s4) or isnan(s5): -return False -return s4 >= s5 -else: -s4 = s1.to_string() -s5 = s2.to_string() -return s4 >= s5 +def compare_gt(x, y): +return _base_compare(x, y, _compare_gt) + + +def compare_ge(x, y): +return _base_compare(x, y, _compare_ge) + + +def compare_lt(x, y): +return _base_compare(y, x, _compare_gt) + + +def compare_le(x, y): +return _base_compare(y, x, _compare_ge) # 11.9.3 -def AbstractEC(ctx, x, y): +def AbstractEC(x, y): """ Implements the Abstract Equality Comparison x == y trying to be fully to the spec @@ -220,19 +228,19 @@ (type1 == "null" and type2 == "undefined"): return True if type1 == "number" and type2 == "string": -return AbstractEC(ctx, x, W_FloatNumber(y.ToNumber())) +return AbstractEC(x, W_FloatNumber(y.ToNumber())) if type1 == "string" and type2 == "number": -return AbstractEC(ctx, W_FloatNumber(x.ToNumber()), y) +return AbstractEC(W_FloatNumber(x.ToNumber()), y) if type1 == "boolean": -return AbstractEC(ctx, W_FloatNumber(x.ToNumber()), y) +return AbstractEC(W_FloatNumber(x.ToNumber()), y) if type2 == "boolean": -return AbstractEC(ctx, x, W_FloatNumber(y.ToNumber())) +return AbstractEC(x, W_FloatNumber(y.ToNumber())) if (type1 == "string" or type1 == "number") and \ type2 == "object": -return AbstractEC(ctx, x, y.ToPrimitive()) +return AbstractEC(x, y.ToPrimitive()) if (type2 == "string" or type2 == "number") and \ type1 == "object": -return AbstractEC(ctx, x.ToPrimitive(), y) +return AbstractEC(x.ToPrimitive(), y) return False objtype = x.GetValue().type() diff --git a/js/object_space.py b/js/object_space.py --- a/js/object_space.py +++ b/js/object_space.py @@ -7,6 +7,16 @@ return isinstance(w, W_IntNumber) +def isstr(w): +from js.jsobj import W_String +return isinstance(w, W_String) + + +def isfloat(w): +from js.jsobj import W_FloatNumber +return isinstance(w, W_FloatNumber) + + @enforceargs(int) def newint(i): from js.jsobj import W_IntNumber @@ -79,7 +89,7 @@ @enforceargs(bool) def newbool(val): -if val is True: +if val: return w_True re
[pypy-commit] lang-js default: Merged changes
Author: Stephan Branch: Changeset: r378:cc983acc4a7f Date: 2013-05-13 09:15 +0200 http://bitbucket.org/pypy/lang-js/changeset/cc983acc4a7f/ Log:Merged changes diff --git a/README.rst b/README.rst new file mode 100644 --- /dev/null +++ b/README.rst @@ -0,0 +1,17 @@ +langjs +== + +langjs is an implementation of javascript programming language, written in +Python using RPython. + +You will need to install some dependencies. You can do it with:: + +pip install -r requirements.txt + +And make sure you have `PyPy_` on your ``PYTHONPATH``. + +To run tests:: + +$ PYTHONPATH=. py.test + +.. _`PyPy`: https://bitbucket.org/pypy/pypy diff --git a/requirements.txt b/requirements.txt new file mode 100644 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,1 @@ +pytest ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Add #ifdefs to our generated decl files
Author: Maciej Fijalkowski Branch: Changeset: r64026:f122c7c37700 Date: 2013-05-13 14:21 +0200 http://bitbucket.org/pypy/pypy/changeset/f122c7c37700/ Log:Add #ifdefs to our generated decl files diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py --- a/rpython/translator/c/genc.py +++ b/rpython/translator/c/genc.py @@ -703,6 +703,8 @@ print >> f, '/***/' print >> f, '/*** Structure definitions ***/' print >> f +print >> f, "#ifndef _PYPY_STRUCTDEF_H" +print >> f, "#define _PYPY_STRUCTDEF_H" for node in structdeflist: if hasattr(node, 'forward_decl'): if node.forward_decl: @@ -713,14 +715,18 @@ for node in structdeflist: for line in node.definition(): print >> f, line +print >> f, "#endif" def gen_forwarddecl(f, database): print >> f, '/***/' print >> f, '/*** Forward declarations ***/' print >> f +print >> f, "#ifndef _PYPY_FORWARDDECL_H" +print >> f, "#define _PYPY_FORWARDDECL_H" for node in database.globalcontainers(): for line in node.forward_declaration(): print >> f, line +print >> f, "#endif" def gen_preimpl(f, database): if database.translator is None or database.translator.rtyper is None: ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-array-smm: Fight with RPython and multimethods
Author: Maciej Fijalkowski Branch: remove-array-smm Changeset: r64027:945a8316f0a8 Date: 2013-05-13 15:33 +0200 http://bitbucket.org/pypy/pypy/changeset/945a8316f0a8/ Log:Fight with RPython and multimethods diff --git a/pypy/module/array/__init__.py b/pypy/module/array/__init__.py --- a/pypy/module/array/__init__.py +++ b/pypy/module/array/__init__.py @@ -1,12 +1,5 @@ from pypy.interpreter.mixedmodule import MixedModule -from pypy.module.array.interp_array import types -from pypy.objspace.std.model import registerimplementation - -for mytype in types.values(): -registerimplementation(mytype.w_class) - - class Module(MixedModule): interpleveldefs = { 'array': 'interp_array.W_ArrayBase', diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py --- a/pypy/module/array/interp_array.py +++ b/pypy/module/array/interp_array.py @@ -4,8 +4,8 @@ from pypy.interpreter.error import OperationError from pypy.interpreter.gateway import interp2app, unwrap_spec, interpindirect2app from pypy.interpreter.typedef import GetSetProperty, make_weakref_descr, TypeDef +from pypy.interpreter.baseobjspace import W_Root from pypy.module._file.interp_file import W_File -from pypy.objspace.std.model import W_Object from rpython.rlib import jit from rpython.rlib.rarithmetic import ovfcheck, widen from rpython.rlib.unroll import unrolling_iterable @@ -105,10 +105,12 @@ return space.w_False return space.w_True +UNICODE_ARRAY = lltype.Ptr(lltype.Array(lltype.UniChar, +hints={'nolength': True})) -class W_ArrayBase(W_Object): +class W_ArrayBase(W_Root): _attrs_ = ('space', 'len', 'allocated', '_lifeline_') # no buffer - + def __init__(self, space): self.space = space self.len = 0 @@ -287,7 +289,8 @@ an array of some other type. """ if self.typecode == 'u': -return space.wrap(rffi.wcharpsize2unicode(self.buffer, self.len)) +buf = rffi.cast(UNICODE_ARRAY, self._buffer_as_unsigned()) +return space.wrap(rffi.wcharpsize2unicode(buf, self.len)) else: msg = "tounicode() may only be called on type 'u' arrays" raise OperationError(space.w_ValueError, space.wrap(msg)) @@ -460,10 +463,6 @@ s = "array('%s', %s)" % (self.typecode, space.str_w(r)) return space.wrap(s) -@staticmethod -def register(typeorder): -typeorder[W_ArrayBase] = [] - W_ArrayBase.typedef = TypeDef( 'array', __new__ = interp2app(w_array), @@ -807,7 +806,7 @@ def getitem_slice(self, space, w_idx): start, stop, step, size = space.decode_index4(w_idx, self.len) -w_a = self.constructor(self.space) +w_a = mytype.w_class(self.space) w_a.setlen(size, overallocate=False) assert step != 0 j = 0 ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-array-smm: please RPython some more
Author: Maciej Fijalkowski Branch: remove-array-smm Changeset: r64028:07a6d73c6b9b Date: 2013-05-13 15:52 +0200 http://bitbucket.org/pypy/pypy/changeset/07a6d73c6b9b/ Log:please RPython some more diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py --- a/pypy/module/array/interp_array.py +++ b/pypy/module/array/interp_array.py @@ -57,14 +57,15 @@ return space.wrap(self.typecode) arr_eq_driver = jit.JitDriver(greens = ['comp_func'], reds = 'auto') +EQ, NE, LT, LE, GT, GE = range(6) -def compare_arrays(space, arr1, arr2, comp_func): +def compare_arrays(space, arr1, arr2, comp_op, comp_func): if (not isinstance(arr1, W_ArrayBase) or not isinstance(arr2, W_ArrayBase)): return space.w_NotImplemented -if comp_func == space.eq and arr1.len != arr2.len: +if comp_op == EQ and arr1.len != arr2.len: return space.w_False -if comp_func == space.ne and arr1.len != arr2.len: +if comp_op == NE and arr1.len != arr2.len: return space.w_True lgt = min(arr1.len, arr2.len) for i in range(lgt): @@ -72,13 +73,13 @@ w_elem1 = arr1.w_getitem(space, i) w_elem2 = arr2.w_getitem(space, i) res = space.is_true(comp_func(w_elem1, w_elem2)) -if comp_func == space.eq: +if comp_op == EQ: if not res: return space.w_False -elif comp_func == space.ne: +elif comp_op == NE: if res: return space.w_True -elif comp_func == space.lt or comp_func == space.gt: +elif comp_op == LT or comp_op == GT: if res: return space.w_True elif not space.is_true(space.eq(w_elem1, w_elem2)): @@ -89,15 +90,15 @@ elif not space.is_true(space.eq(w_elem1, w_elem2)): return space.w_True # we have some leftovers -if comp_func == space.eq: +if comp_op == EQ: return space.w_True -elif comp_func == space.ne: +elif comp_op == NE: return space.w_False if arr1.len == arr2.len: -if comp_func == space.lt or comp_func == space.gt: +if comp_op == LT or comp_op == GT: return space.w_False return space.w_True -if comp_func == space.lt or comp_func == space.le: +if comp_op == LT or comp_op == LE: if arr1.len < arr2.len: return space.w_False return space.w_True @@ -361,27 +362,27 @@ def descr_eq(self, space, w_arr2): "x.__eq__(y) <==> x==y" -return compare_arrays(space, self, w_arr2, space.eq) +return compare_arrays(space, self, w_arr2, EQ, space.eq) def descr_ne(self, space, w_arr2): "x.__ne__(y) <==> x!=y" -return compare_arrays(space, self, w_arr2, space.ne) +return compare_arrays(space, self, w_arr2, NE, space.ne) def descr_lt(self, space, w_arr2): "x.__lt__(y) <==> x x<=y" -return compare_arrays(space, self, w_arr2, space.le) +return compare_arrays(space, self, w_arr2, LE, space.le) def descr_gt(self, space, w_arr2): "x.__gt__(y) <==> x>y" -return compare_arrays(space, self, w_arr2, space.gt) +return compare_arrays(space, self, w_arr2, GT, space.gt) def descr_ge(self, space, w_arr2): "x.__ge__(y) <==> x>=y" -return compare_arrays(space, self, w_arr2, space.ge) +return compare_arrays(space, self, w_arr2, GE, space.ge) # Basic get/set/append/extend methods ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-subarrays: Start fixing test_zjit
Author: Romain Guillebert Branch: numpy-subarrays Changeset: r64030:87e24d1ab3cc Date: 2013-05-13 16:09 +0200 http://bitbucket.org/pypy/pypy/changeset/87e24d1ab3cc/ Log:Start fixing test_zjit diff --git a/pypy/module/micronumpy/interp_dtype.py b/pypy/module/micronumpy/interp_dtype.py --- a/pypy/module/micronumpy/interp_dtype.py +++ b/pypy/module/micronumpy/interp_dtype.py @@ -286,12 +286,12 @@ for w_elem in lst_w: size = 1 w_shape = space.newtuple([]) -if space.len_w(w_elem) >2: -w_shape = space.getitem(w_elem, space.wrap(2)) +if space.len_w(w_elem) == 3: +w_fldname, w_flddesc, w_shape = space.fixedview(w_elem) if not base.issequence_w(space, w_shape): w_shape = space.newtuple([w_shape,]) -w_fldname = space.getitem(w_elem, space.wrap(0)) -w_flddesc = space.getitem(w_elem, space.wrap(1)) +else: +w_fldname, w_flddesc = space.fixedview(w_elem) subdtype = descr__new__(space, space.gettypefor(W_Dtype), w_flddesc, w_shape=w_shape) fldname = space.str_w(w_fldname) if fldname in fields: diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py --- a/pypy/module/micronumpy/types.py +++ b/pypy/module/micronumpy/types.py @@ -1733,7 +1733,7 @@ if not space.issequence_w(w_item): raise OperationError(space.w_TypeError, space.wrap( "expected sequence")) -if len(self.offsets_and_fields) != space.int_w(space.len(w_item)): +if len(self.offsets_and_fields) != space.len_w(w_item): raise OperationError(space.w_ValueError, space.wrap( "wrong length")) items_w = space.fixedview(w_item) ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Add more embedding API, I think this is right, but very hard to test
Author: Maciej Fijalkowski Branch: Changeset: r64029:a1b20d7f239c Date: 2013-05-13 16:16 +0200 http://bitbucket.org/pypy/pypy/changeset/a1b20d7f239c/ Log:Add more embedding API, I think this is right, but very hard to test diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py --- a/pypy/goal/targetpypystandalone.py +++ b/pypy/goal/targetpypystandalone.py @@ -2,6 +2,7 @@ import os, sys +import pypy from pypy.interpreter import gateway from pypy.interpreter.error import OperationError from pypy.tool.ann_override import PyPyAnnotatorPolicy @@ -80,6 +81,24 @@ from rpython.rlib.entrypoint import entrypoint from rpython.rtyper.lltypesystem import rffi +@entrypoint('main', [rffi.CCHARP], c_name='pypy_setup_home') +def pypy_setup_home(ll_home): +from pypy.module.sys.initpath import pypy_find_stdlib +if ll_home: +home = rffi.charp2str(ll_home) +else: +home = pypydir +pypy_find_stdlib(space, home) +space.startup() +# import site +try: +import_ = space.getattr(space.getbuiltinmodule('__builtin__'), +space.wrap('__import__')) +space.call_function(import_, space.wrap('site')) +return 0 +except OperationError: +return 1 + @entrypoint('main', [rffi.CCHARP], c_name='pypy_execute_source') def pypy_execute_source(ll_source): source = rffi.charp2str(ll_source) @@ -101,7 +120,8 @@ return 1 return 0 -return entry_point, _pypy_execute_source # for tests +return entry_point, {'pypy_execute_source': pypy_execute_source, + 'pypy_setup_home': pypy_setup_home} def call_finish(space): space.finish() diff --git a/pypy/interpreter/test/test_targetpypy.py b/pypy/interpreter/test/test_targetpypy.py --- a/pypy/interpreter/test/test_targetpypy.py +++ b/pypy/interpreter/test/test_targetpypy.py @@ -1,5 +1,6 @@ from pypy.goal.targetpypystandalone import get_entry_point, create_entry_point from pypy.config.pypyoption import get_pypy_config +from rpython.rtyper.lltypesystem import rffi, lltype class TestTargetPyPy(object): def test_run(self): @@ -8,11 +9,20 @@ entry_point(['pypy-c' , '-S', '-c', 'print 3']) def test_exeucte_source(space): -_, execute_source = create_entry_point(space, None) -execute_source("import sys; sys.modules['xyz'] = 3") +_, d = create_entry_point(space, None) +execute_source = d['pypy_execute_source'] +lls = rffi.str2charp("import sys; sys.modules['xyz'] = 3") +execute_source(lls) +lltype.free(lls, flavor='raw') x = space.int_w(space.getitem(space.getattr(space.builtin_modules['sys'], space.wrap('modules')), space.wrap('xyz'))) assert x == 3 -execute_source("sys") +lls = rffi.str2charp("sys") +execute_source(lls) +lltype.free(lls, flavor='raw') # did not crash - the same globals +pypy_setup_home = d['pypy_setup_home'] +lls = rffi.str2charp(__file__) +pypy_setup_home(lls) +lltype.free(lls, flavor='raw') diff --git a/rpython/rlib/entrypoint.py b/rpython/rlib/entrypoint.py --- a/rpython/rlib/entrypoint.py +++ b/rpython/rlib/entrypoint.py @@ -29,6 +29,7 @@ if not we_are_translated(): import traceback traceback.print_exc() +raise else: print str(e) pypy_debug_catch_fatal_exception() ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-array-smm: merge default
Author: Maciej Fijalkowski Branch: remove-array-smm Changeset: r64031:fa05eb32023c Date: 2013-05-13 17:36 +0200 http://bitbucket.org/pypy/pypy/changeset/fa05eb32023c/ Log:merge default diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py --- a/pypy/goal/targetpypystandalone.py +++ b/pypy/goal/targetpypystandalone.py @@ -2,6 +2,7 @@ import os, sys +import pypy from pypy.interpreter import gateway from pypy.interpreter.error import OperationError from pypy.tool.ann_override import PyPyAnnotatorPolicy @@ -80,6 +81,24 @@ from rpython.rlib.entrypoint import entrypoint from rpython.rtyper.lltypesystem import rffi +@entrypoint('main', [rffi.CCHARP], c_name='pypy_setup_home') +def pypy_setup_home(ll_home): +from pypy.module.sys.initpath import pypy_find_stdlib +if ll_home: +home = rffi.charp2str(ll_home) +else: +home = pypydir +pypy_find_stdlib(space, home) +space.startup() +# import site +try: +import_ = space.getattr(space.getbuiltinmodule('__builtin__'), +space.wrap('__import__')) +space.call_function(import_, space.wrap('site')) +return 0 +except OperationError: +return 1 + @entrypoint('main', [rffi.CCHARP], c_name='pypy_execute_source') def pypy_execute_source(ll_source): source = rffi.charp2str(ll_source) @@ -101,7 +120,8 @@ return 1 return 0 -return entry_point, _pypy_execute_source # for tests +return entry_point, {'pypy_execute_source': pypy_execute_source, + 'pypy_setup_home': pypy_setup_home} def call_finish(space): space.finish() diff --git a/pypy/interpreter/test/test_targetpypy.py b/pypy/interpreter/test/test_targetpypy.py --- a/pypy/interpreter/test/test_targetpypy.py +++ b/pypy/interpreter/test/test_targetpypy.py @@ -1,5 +1,6 @@ from pypy.goal.targetpypystandalone import get_entry_point, create_entry_point from pypy.config.pypyoption import get_pypy_config +from rpython.rtyper.lltypesystem import rffi, lltype class TestTargetPyPy(object): def test_run(self): @@ -8,11 +9,20 @@ entry_point(['pypy-c' , '-S', '-c', 'print 3']) def test_exeucte_source(space): -_, execute_source = create_entry_point(space, None) -execute_source("import sys; sys.modules['xyz'] = 3") +_, d = create_entry_point(space, None) +execute_source = d['pypy_execute_source'] +lls = rffi.str2charp("import sys; sys.modules['xyz'] = 3") +execute_source(lls) +lltype.free(lls, flavor='raw') x = space.int_w(space.getitem(space.getattr(space.builtin_modules['sys'], space.wrap('modules')), space.wrap('xyz'))) assert x == 3 -execute_source("sys") +lls = rffi.str2charp("sys") +execute_source(lls) +lltype.free(lls, flavor='raw') # did not crash - the same globals +pypy_setup_home = d['pypy_setup_home'] +lls = rffi.str2charp(__file__) +pypy_setup_home(lls) +lltype.free(lls, flavor='raw') diff --git a/rpython/rlib/entrypoint.py b/rpython/rlib/entrypoint.py --- a/rpython/rlib/entrypoint.py +++ b/rpython/rlib/entrypoint.py @@ -29,6 +29,7 @@ if not we_are_translated(): import traceback traceback.print_exc() +raise else: print str(e) pypy_debug_catch_fatal_exception() diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py --- a/rpython/translator/c/genc.py +++ b/rpython/translator/c/genc.py @@ -703,6 +703,8 @@ print >> f, '/***/' print >> f, '/*** Structure definitions ***/' print >> f +print >> f, "#ifndef _PYPY_STRUCTDEF_H" +print >> f, "#define _PYPY_STRUCTDEF_H" for node in structdeflist: if hasattr(node, 'forward_decl'): if node.forward_decl: @@ -713,14 +715,18 @@ for node in structdeflist: for line in node.definition(): print >> f, line +print >> f, "#endif" def gen_forwarddecl(f, database): print >> f, '/***/' print >> f, '/*** Forward declarations ***/' print >> f +print >> f, "#ifndef _PYPY_FORWARDDECL_H" +print >> f, "#define _PYPY_FORWARDDECL_H" for node in database.globalcontainers(): for line in node.forward_declaration(): print >> f, line +print >> f, "#endif" def gen_preimpl(f, database): if database.translator is None or database.translator.rtyper is None: ___ pypy-commit mailing list pypy-commit@python.org http://mai
[pypy-commit] pypy default: fix the test - secondary callbacks now do that
Author: Maciej Fijalkowski Branch: Changeset: r64032:afb35608bfbf Date: 2013-05-13 17:54 +0200 http://bitbucket.org/pypy/pypy/changeset/afb35608bfbf/ Log:fix the test - secondary callbacks now do that diff --git a/rpython/translator/c/gcc/test/test_asmgcroot.py b/rpython/translator/c/gcc/test/test_asmgcroot.py --- a/rpython/translator/c/gcc/test/test_asmgcroot.py +++ b/rpython/translator/c/gcc/test/test_asmgcroot.py @@ -195,10 +195,7 @@ @entrypoint("x42", [lltype.Signed, lltype.Signed], c_name='callback') def mycallback(a, b): -rffi.stackcounter.stacks_counter += 1 -llop.gc_stack_bottom(lltype.Void) gc.collect() -rffi.stackcounter.stacks_counter -= 1 return a + b c_source = py.code.Source(""" ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: add armhf to getnightly
Author: David Schneider Branch: Changeset: r64033:97989d13642c Date: 2013-05-13 18:53 +0200 http://bitbucket.org/pypy/pypy/changeset/97989d13642c/ Log:add armhf to getnightly diff --git a/pypy/goal/getnightly.py b/pypy/goal/getnightly.py --- a/pypy/goal/getnightly.py +++ b/pypy/goal/getnightly.py @@ -8,7 +8,9 @@ arch = 'linux' cmd = 'wget "%s"' tar = "tar -x -v --wildcards --strip-components=2 -f %s '*/bin/pypy'" -if sys.platform.startswith('darwin'): +if os.uname()[-1].startswith('arm'): +arch += '-armhf-raspbian' +elif sys.platform.startswith('darwin'): arch = 'osx' cmd = 'curl -O "%s"' tar = "tar -x -v --strip-components=2 -f %s '*/bin/pypy'" ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy.org extradoc: Donation sidebar fix for ie
Author: Arseniy Terekhin Branch: extradoc Changeset: r426:760313371d05 Date: 2013-04-21 18:32 +0400 http://bitbucket.org/pypy/pypy.org/changeset/760313371d05/ Log:Donation sidebar fix for ie diff --git a/js/script2.js b/js/script2.js --- a/js/script2.js +++ b/js/script2.js @@ -1,28 +1,21 @@ +function set_sidebar_html(html) { +$("#sidebar").html(html); +} function py3k_donate() { -$.get("don1.html#", function (html) { -$("#sidebar").html(html); -}); +$.get("don1.html", set_sidebar_html); } function stm_donate() { -$.get("don4.html#", function (html) { -$("#sidebar").html(html); -}); +$.get("don4.html", set_sidebar_html); } function general_donate() { -$.get("don2.html#", function (html) { -$("#sidebar").html(html); -}); +$.get("don2.html", set_sidebar_html); } function numpy_donate() { -$.get("don3.html#", function (html) { -$("#sidebar").html(html); -}); +$.get("don3.html", set_sidebar_html); } -$(document).ready(function() { -stm_donate(); -}); \ No newline at end of file +$(document).ready(stm_donate); ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy.org extradoc: Menu padding (as logo)
Author: Arseniy Terekhin Branch: extradoc Changeset: r428:e0901e09d0c9 Date: 2013-04-21 20:29 +0400 http://bitbucket.org/pypy/pypy.org/changeset/e0901e09d0c9/ Log:Menu padding (as logo) diff --git a/css/site.css b/css/site.css --- a/css/site.css +++ b/css/site.css @@ -353,6 +353,7 @@ #menu-follow { float: right; + margin-top: 17px; } #menu-follow div { ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy.org extradoc: Do not wrap menu items, space between menu lines.
Author: Arseniy Terekhin Branch: extradoc Changeset: r429:a7aa0843cf10 Date: 2013-04-21 20:51 +0400 http://bitbucket.org/pypy/pypy.org/changeset/a7aa0843cf10/ Log:Do not wrap menu items, space between menu lines. diff --git a/css/site.css b/css/site.css --- a/css/site.css +++ b/css/site.css @@ -380,6 +380,11 @@ font-size: 1em; padding-bottom: 10px; text-align: center; + line-height:1.75em; +} + +#menu-sub a{ + white-space: nowrap; } .menu-sub-sep { ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-subarrays: Add a numarray test for subarrays.
Author: Romain Guillebert Branch: numpy-subarrays Changeset: r64039:41899867e728 Date: 2013-05-13 19:50 +0200 http://bitbucket.org/pypy/pypy/changeset/41899867e728/ Log:Add a numarray test for subarrays. diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py --- a/pypy/module/micronumpy/test/test_numarray.py +++ b/pypy/module/micronumpy/test/test_numarray.py @@ -2699,6 +2699,15 @@ assert a[0]['y'] == 2 assert a[1]['y'] == 1 +def test_subarrays(self): +from numpypy import dtype, array + +d = dtype([("x", "int", 3), ("y", "float", 5)]) +a = array([([1, 2, 3], [0.5, 1.5, 2.5, 3.5, 4.5])], dtype=d) + +assert a[0]["x"] == [1, 2, 3].all() +assert a[1]["y"] == [0.5, 1.5, 2.5, 3.5, 4.5].all() + class AppTestPyPy(BaseNumpyAppTest): def setup_class(cls): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3k: fix translation
Author: Philip Jenvey Branch: py3k Changeset: r64038:111b6f1d63f4 Date: 2013-05-13 10:50 -0700 http://bitbucket.org/pypy/pypy/changeset/111b6f1d63f4/ Log:fix translation diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -1395,7 +1395,8 @@ return space.newtuple([w_new_inst, w_args, w_state]) def descr_setstate(self, space, w_state): -self.operr = OperationError(*space.fixedview(w_state, 3)) +w_type, w_value, w_tb = space.fixedview(w_state, 3) +self.operr = OperationError(w_type, w_value, w_tb) def source_as_str(space, w_source, funcname, what, flags): """Return source code as str0 with adjusted compiler flags ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy numpy-subarrays: Start to make VoidType subarray friendly
Author: Romain Guillebert Branch: numpy-subarrays Changeset: r64040:3acd856274de Date: 2013-05-13 19:51 +0200 http://bitbucket.org/pypy/pypy/changeset/3acd856274de/ Log:Start to make VoidType subarray friendly diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py --- a/pypy/module/micronumpy/types.py +++ b/pypy/module/micronumpy/types.py @@ -1700,6 +1700,24 @@ class VoidType(BaseType, BaseStringType): T = lltype.Char +def coerce(self, space, dtype, w_items): +items_w = space.fixedview(w_items) +arr = VoidBoxStorage(self.size, dtype) +ofs = 0 +for i in range(len(items_w)): +subdtype = dtype.subdtype +itemtype = subdtype.itemtype +w_box = itemtype.coerce(space, dtype.subdtype, items_w[i]) +itemtype.store(arr, 0, ofs, w_box) +ofs += itemtype.get_element_size() +return interp_boxes.W_VoidBox(arr, 0, dtype) + +@jit.unroll_safe +def store(self, arr, i, ofs, box): +assert isinstance(box, interp_boxes.W_VoidBox) +for k in range(self.get_element_size()): +arr.storage[k + ofs] = box.arr.storage[k + box.ofs] + NonNativeVoidType = VoidType NonNativeStringType = StringType ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: improve error reporting
Author: Maciej Fijalkowski Branch: Changeset: r64041:082d3fee772a Date: 2013-05-13 19:54 +0200 http://bitbucket.org/pypy/pypy/changeset/082d3fee772a/ Log:improve error reporting diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py --- a/pypy/goal/targetpypystandalone.py +++ b/pypy/goal/targetpypystandalone.py @@ -79,16 +79,19 @@ # should be used as sparsely as possible, just to register callbacks from rpython.rlib.entrypoint import entrypoint -from rpython.rtyper.lltypesystem import rffi +from rpython.rtyper.lltypesystem import rffi, lltype -@entrypoint('main', [rffi.CCHARP], c_name='pypy_setup_home') -def pypy_setup_home(ll_home): +@entrypoint('main', [rffi.CCHARP, lltype.Signed], c_name='pypy_setup_home') +def pypy_setup_home(ll_home, verbose): from pypy.module.sys.initpath import pypy_find_stdlib if ll_home: home = rffi.charp2str(ll_home) else: home = pypydir -pypy_find_stdlib(space, home) +if space.is_none(pypy_find_stdlib(space, home)): +if verbose: +debug("Failed to find library based on pypy_find_stdlib") +return 1 space.startup() # import site try: @@ -96,7 +99,11 @@ space.wrap('__import__')) space.call_function(import_, space.wrap('site')) return 0 -except OperationError: +except OperationError, e: +if verbose: +debug("OperationError:") +debug(" operror-type: " + e.w_type.getname(space)) +debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space return 1 @entrypoint('main', [rffi.CCHARP], c_name='pypy_execute_source') diff --git a/pypy/interpreter/test/test_targetpypy.py b/pypy/interpreter/test/test_targetpypy.py --- a/pypy/interpreter/test/test_targetpypy.py +++ b/pypy/interpreter/test/test_targetpypy.py @@ -24,5 +24,5 @@ # did not crash - the same globals pypy_setup_home = d['pypy_setup_home'] lls = rffi.str2charp(__file__) -pypy_setup_home(lls) +pypy_setup_home(lls, 1) lltype.free(lls, flavor='raw') ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge
Author: Maciej Fijalkowski Branch: Changeset: r64042:259bdfb96071 Date: 2013-05-13 19:55 +0200 http://bitbucket.org/pypy/pypy/changeset/259bdfb96071/ Log:merge diff --git a/pypy/goal/getnightly.py b/pypy/goal/getnightly.py --- a/pypy/goal/getnightly.py +++ b/pypy/goal/getnightly.py @@ -8,7 +8,9 @@ arch = 'linux' cmd = 'wget "%s"' tar = "tar -x -v --wildcards --strip-components=2 -f %s '*/bin/pypy'" -if sys.platform.startswith('darwin'): +if os.uname()[-1].startswith('arm'): +arch += '-armhf-raspbian' +elif sys.platform.startswith('darwin'): arch = 'osx' cmd = 'curl -O "%s"' tar = "tar -x -v --strip-components=2 -f %s '*/bin/pypy'" ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: kill the specialization here
Author: Maciej Fijalkowski Branch: Changeset: r64043:5aeca6395228 Date: 2013-05-13 21:23 +0200 http://bitbucket.org/pypy/pypy/changeset/5aeca6395228/ Log:kill the specialization here 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 @@ -548,7 +548,6 @@ [name.startswith("w_") for name in names]))) fatal_value = callable.api_func.restype._defl() -@specialize.ll() def wrapper(*args): from pypy.module.cpyext.pyobject import make_ref, from_ref from pypy.module.cpyext.pyobject import Reference ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy remove-array-smm: Oops (thanks amaury)
Author: Maciej Fijalkowski Branch: remove-array-smm Changeset: r64044:ead38baf8c3e Date: 2013-05-13 21:56 +0200 http://bitbucket.org/pypy/pypy/changeset/ead38baf8c3e/ Log:Oops (thanks amaury) diff --git a/pypy/module/array/test/test_ztranslation.py b/pypy/module/array/test/test_ztranslation.py --- a/pypy/module/array/test/test_ztranslation.py +++ b/pypy/module/array/test/test_ztranslation.py @@ -2,5 +2,5 @@ from pypy.objspace.fake.checkmodule import checkmodule def test_checkmodule(): -checkmodule('struct') +checkmodule('array') ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: move JitException subclasses to jitexc module
Author: Benjamin Peterson Branch: Changeset: r64045:71b42a2d862d Date: 2013-05-13 15:04 -0500 http://bitbucket.org/pypy/pypy/changeset/71b42a2d862d/ Log:move JitException subclasses to jitexc module diff --git a/rpython/jit/metainterp/blackhole.py b/rpython/jit/metainterp/blackhole.py --- a/rpython/jit/metainterp/blackhole.py +++ b/rpython/jit/metainterp/blackhole.py @@ -1,7 +1,8 @@ from rpython.jit.codewriter import heaptracker, longlong from rpython.jit.codewriter.jitcode import JitCode, SwitchDictDescr from rpython.jit.metainterp.compile import ResumeAtPositionDescr -from rpython.jit.metainterp.jitexc import JitException, get_llexception, reraise +from rpython.jit.metainterp.jitexc import get_llexception, reraise +from rpython.jit.metainterp import jitexc from rpython.rlib import longlong2float from rpython.rlib.debug import ll_assert, make_sure_not_resized from rpython.rlib.objectmodel import we_are_translated @@ -25,7 +26,7 @@ LONGLONG_TYPECODE = 'i' if longlong.is_64_bit else 'f' -class LeaveFrame(JitException): +class LeaveFrame(jitexc.JitException): pass class MissingValue(object): @@ -306,7 +307,7 @@ self.dispatch_loop(self, self.jitcode.code, self.position) except LeaveFrame: break -except JitException: +except jitexc.JitException: raise # go through except Exception, e: lle = get_llexception(self.cpu, e) @@ -902,8 +903,7 @@ @arguments("self", "i", "I", "R", "F", "I", "R", "F") def bhimpl_jit_merge_point(self, jdindex, *args): if self.nextblackholeinterp is None:# we are the last level -CRN = self.builder.metainterp_sd.ContinueRunningNormally -raise CRN(*args) +raise jitexc.ContinueRunningNormally(*args) # Note that the case above is an optimization: the case # below would work too. But it keeps unnecessary stuff on # the stack; the solution above first gets rid of the blackhole @@ -1400,7 +1400,7 @@ # we now proceed to interpret the bytecode in this frame self.run() # -except JitException, e: +except jitexc.JitException, e: raise # go through except Exception, e: # if we get an exception, return it to the caller frame @@ -1495,20 +1495,20 @@ sd = self.builder.metainterp_sd kind = self._return_type if kind == 'v': -raise sd.DoneWithThisFrameVoid() +raise jitexc.DoneWithThisFrameVoid() elif kind == 'i': -raise sd.DoneWithThisFrameInt(self.get_tmpreg_i()) +raise jitexc.DoneWithThisFrameInt(self.get_tmpreg_i()) elif kind == 'r': -raise sd.DoneWithThisFrameRef(self.cpu, self.get_tmpreg_r()) +raise jitexc.DoneWithThisFrameRef(self.cpu, self.get_tmpreg_r()) elif kind == 'f': -raise sd.DoneWithThisFrameFloat(self.get_tmpreg_f()) +raise jitexc.DoneWithThisFrameFloat(self.get_tmpreg_f()) else: assert False def _exit_frame_with_exception(self, e): sd = self.builder.metainterp_sd e = lltype.cast_opaque_ptr(llmemory.GCREF, e) -raise sd.ExitFrameWithExceptionRef(self.cpu, e) +raise jitexc.ExitFrameWithExceptionRef(self.cpu, e) def _handle_jitexception_in_portal(self, e): # This case is really rare, but can occur if @@ -1558,23 +1558,23 @@ while True: try: current_exc = blackholeinterp._resume_mainloop(current_exc) -except JitException, e: +except jitexc.JitException as e: blackholeinterp, current_exc = _handle_jitexception( blackholeinterp, e) blackholeinterp.builder.release_interp(blackholeinterp) blackholeinterp = blackholeinterp.nextblackholeinterp -def _handle_jitexception(blackholeinterp, jitexc): +def _handle_jitexception(blackholeinterp, exc): # See comments in _handle_jitexception_in_portal(). while not blackholeinterp.jitcode.is_portal: blackholeinterp.builder.release_interp(blackholeinterp) blackholeinterp = blackholeinterp.nextblackholeinterp if blackholeinterp.nextblackholeinterp is None: blackholeinterp.builder.release_interp(blackholeinterp) -raise jitexc # bottommost entry: go through +raise exc # bottommost entry: go through # We have reached a recursive portal level. try: -blackholeinterp._handle_jitexception_in_portal(jitexc) +blackholeinterp._handle_jitexception_in_portal(exc) except Exception, e: # It raised a general exception (it should not be a JitException here). lle = get_llexception(blackholeinterp.cpu, e) diff --git a/rpython/jit/metainterp/compile.py b/rpython/jit/metainterp/compile.py --- a/rpython/jit/metainterp/comp
[pypy-commit] pypy remove-array-smm: close to-be-merged branch
Author: Maciej Fijalkowski Branch: remove-array-smm Changeset: r64046:9913b5d0c7d3 Date: 2013-05-13 22:44 +0200 http://bitbucket.org/pypy/pypy/changeset/9913b5d0c7d3/ Log:close to-be-merged branch ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Merge remove-array-smm branch that kills multimethods from the array module
Author: Maciej Fijalkowski Branch: Changeset: r64047:d1459869ce85 Date: 2013-05-13 22:44 +0200 http://bitbucket.org/pypy/pypy/changeset/d1459869ce85/ Log:Merge remove-array-smm branch that kills multimethods from the array module diff --git a/pypy/module/array/__init__.py b/pypy/module/array/__init__.py --- a/pypy/module/array/__init__.py +++ b/pypy/module/array/__init__.py @@ -1,12 +1,5 @@ from pypy.interpreter.mixedmodule import MixedModule -from pypy.module.array.interp_array import types -from pypy.objspace.std.model import registerimplementation - -for mytype in types.values(): -registerimplementation(mytype.w_class) - - class Module(MixedModule): interpleveldefs = { 'array': 'interp_array.W_ArrayBase', diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py --- a/pypy/module/array/interp_array.py +++ b/pypy/module/array/interp_array.py @@ -2,17 +2,14 @@ from pypy.interpreter.buffer import RWBuffer from pypy.interpreter.error import OperationError -from pypy.interpreter.gateway import interp2app, unwrap_spec -from pypy.interpreter.typedef import GetSetProperty, make_weakref_descr +from pypy.interpreter.gateway import interp2app, unwrap_spec, interpindirect2app +from pypy.interpreter.typedef import GetSetProperty, make_weakref_descr, TypeDef +from pypy.interpreter.baseobjspace import W_Root from pypy.module._file.interp_file import W_File -from pypy.objspace.std.model import W_Object -from pypy.objspace.std.multimethod import FailedToImplement -from pypy.objspace.std.stdtypedef import SMM, StdTypeDef -from pypy.objspace.std.register_all import register_all from rpython.rlib import jit from rpython.rlib.rarithmetic import ovfcheck, widen from rpython.rlib.unroll import unrolling_iterable -from rpython.rlib.objectmodel import specialize, keepalive_until_here +from rpython.rlib.objectmodel import keepalive_until_here from rpython.rtyper.lltypesystem import lltype, rffi @@ -39,9 +36,9 @@ if len(__args__.arguments_w) > 0: w_initializer = __args__.arguments_w[0] if space.type(w_initializer) is space.w_str: -a.fromstring(space.str_w(w_initializer)) +a.descr_fromstring(space, space.str_w(w_initializer)) elif space.type(w_initializer) is space.w_list: -a.fromlist(w_initializer) +a.descr_fromlist(space, w_initializer) else: a.extend(w_initializer, True) break @@ -52,31 +49,6 @@ return a -array_append = SMM('append', 2) -array_extend = SMM('extend', 2) - -array_count = SMM('count', 2) -array_index = SMM('index', 2) -array_reverse = SMM('reverse', 1) -array_remove = SMM('remove', 2) -array_pop = SMM('pop', 2, defaults=(-1,)) -array_insert = SMM('insert', 3) - -array_tolist = SMM('tolist', 1) -array_fromlist = SMM('fromlist', 2) -array_tostring = SMM('tostring', 1) -array_fromstring = SMM('fromstring', 2) -array_tounicode = SMM('tounicode', 1) -array_fromunicode = SMM('fromunicode', 2) -array_tofile = SMM('tofile', 2) -array_fromfile = SMM('fromfile', 3) - -array_buffer_info = SMM('buffer_info', 1) -array_reduce = SMM('__reduce__', 1) -array_copy = SMM('__copy__', 1) -array_byteswap = SMM('byteswap', 1) - - def descr_itemsize(space, self): return space.wrap(self.itemsize) @@ -84,28 +56,476 @@ def descr_typecode(space, self): return space.wrap(self.typecode) +arr_eq_driver = jit.JitDriver(greens = ['comp_func'], reds = 'auto') +EQ, NE, LT, LE, GT, GE = range(6) -class W_ArrayBase(W_Object): -@staticmethod -def register(typeorder): -typeorder[W_ArrayBase] = [] +def compare_arrays(space, arr1, arr2, comp_op, comp_func): +if (not isinstance(arr1, W_ArrayBase) or +not isinstance(arr2, W_ArrayBase)): +return space.w_NotImplemented +if comp_op == EQ and arr1.len != arr2.len: +return space.w_False +if comp_op == NE and arr1.len != arr2.len: +return space.w_True +lgt = min(arr1.len, arr2.len) +for i in range(lgt): +arr_eq_driver.jit_merge_point(comp_func=comp_func) +w_elem1 = arr1.w_getitem(space, i) +w_elem2 = arr2.w_getitem(space, i) +res = space.is_true(comp_func(w_elem1, w_elem2)) +if comp_op == EQ: +if not res: +return space.w_False +elif comp_op == NE: +if res: +return space.w_True +elif comp_op == LT or comp_op == GT: +if res: +return space.w_True +elif not space.is_true(space.eq(w_elem1, w_elem2)): +return space.w_False +else: +if not res: +return space.w_False +elif not space.is_true(space.eq(w_elem1, w_elem2)): +return space.w_True +# we have some leftovers +if comp_op == EQ: +return space.w_True +elif
[pypy-commit] pypy default: Use modern version of @unwrap_spec
Author: Amaury Forgeot d'Arc Branch: Changeset: r64048:84ff58711a5d Date: 2013-05-13 22:53 +0200 http://bitbucket.org/pypy/pypy/changeset/84ff58711a5d/ Log:Use modern version of @unwrap_spec 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 @@ -1,4 +1,3 @@ -from pypy.interpreter.baseobjspace import ObjSpace, W_Root from pypy.interpreter.error import OperationError, wrap_oserror from pypy.interpreter.gateway import unwrap_spec from rpython.rlib.objectmodel import we_are_translated @@ -56,7 +55,7 @@ bltn = BuiltinFunction(func) return space.wrap(bltn) -@unwrap_spec(ObjSpace, W_Root, str) +@unwrap_spec(meth=str) def lookup_special(space, w_obj, meth): """Lookup up a special method on an object.""" if space.is_oldstyle_instance(w_obj): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: actually set the path
Author: Maciej Fijalkowski Branch: Changeset: r64049:0139e1989670 Date: 2013-05-13 23:10 +0200 http://bitbucket.org/pypy/pypy/changeset/0139e1989670/ Log:actually set the path diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py --- a/pypy/goal/targetpypystandalone.py +++ b/pypy/goal/targetpypystandalone.py @@ -81,6 +81,13 @@ from rpython.rlib.entrypoint import entrypoint from rpython.rtyper.lltypesystem import rffi, lltype +w_pathsetter = space.appexec([], """(): +def f(path): +import sys +sys.path[:] = path +return f +""") + @entrypoint('main', [rffi.CCHARP, lltype.Signed], c_name='pypy_setup_home') def pypy_setup_home(ll_home, verbose): from pypy.module.sys.initpath import pypy_find_stdlib @@ -88,11 +95,13 @@ home = rffi.charp2str(ll_home) else: home = pypydir -if space.is_none(pypy_find_stdlib(space, home)): +w_path = pypy_find_stdlib(space, home) +if space.is_none(w_path): if verbose: debug("Failed to find library based on pypy_find_stdlib") return 1 space.startup() +space.call_function(w_pathsetter, w_path) # import site try: import_ = space.getattr(space.getbuiltinmodule('__builtin__'), ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge
Author: Maciej Fijalkowski Branch: Changeset: r64050:bcf984fdbff0 Date: 2013-05-13 23:11 +0200 http://bitbucket.org/pypy/pypy/changeset/bcf984fdbff0/ Log:merge 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 @@ -1,4 +1,3 @@ -from pypy.interpreter.baseobjspace import ObjSpace, W_Root from pypy.interpreter.error import OperationError, wrap_oserror from pypy.interpreter.gateway import unwrap_spec from rpython.rlib.objectmodel import we_are_translated @@ -56,7 +55,7 @@ bltn = BuiltinFunction(func) return space.wrap(bltn) -@unwrap_spec(ObjSpace, W_Root, str) +@unwrap_spec(meth=str) def lookup_special(space, w_obj, meth): """Lookup up a special method on an object.""" if space.is_oldstyle_instance(w_obj): ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy improve-docs: Move index.rst to index_old.rst.
Author: Manuel Jacob Branch: improve-docs Changeset: r64051:4c410b98dea5 Date: 2013-05-13 23:18 +0200 http://bitbucket.org/pypy/pypy/changeset/4c410b98dea5/ Log:Move index.rst to index_old.rst. diff --git a/pypy/doc/index.rst b/pypy/doc/index-old.rst rename from pypy/doc/index.rst rename to pypy/doc/index-old.rst ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy improve-docs: Add skeleton for new index.rst.
Author: Manuel Jacob Branch: improve-docs Changeset: r64052:1c45dad848d0 Date: 2013-05-13 23:19 +0200 http://bitbucket.org/pypy/pypy/changeset/1c45dad848d0/ Log:Add skeleton for new index.rst. diff --git a/pypy/doc/index.rst b/pypy/doc/index.rst new file mode 100644 --- /dev/null +++ b/pypy/doc/index.rst @@ -0,0 +1,40 @@ +Welcome to PyPy's documentation! + + +.. TODO write introduction + + +User documentation +-- + +.. toctree:: + :maxdepth: 2 + + +Development documentation +- + +.. toctree:: + :maxdepth: 2 + + +Academical stuff + + +.. toctree:: + :maxdepth: 2 + + +Contact +--- + +.. TODO add contact information + + +Indices and tables +== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy improve-docs: Add skeletons for install.rst and build.rst.
Author: Manuel Jacob Branch: improve-docs Changeset: r64053:614e85af2364 Date: 2013-05-13 23:38 +0200 http://bitbucket.org/pypy/pypy/changeset/614e85af2364/ Log:Add skeletons for install.rst and build.rst. diff --git a/pypy/doc/build.rst b/pypy/doc/build.rst new file mode 100644 --- /dev/null +++ b/pypy/doc/build.rst @@ -0,0 +1,2 @@ +Building PyPy from Source += diff --git a/pypy/doc/index.rst b/pypy/doc/index.rst --- a/pypy/doc/index.rst +++ b/pypy/doc/index.rst @@ -10,6 +10,9 @@ .. toctree:: :maxdepth: 2 + install + build + Development documentation - diff --git a/pypy/doc/install.rst b/pypy/doc/install.rst new file mode 100644 --- /dev/null +++ b/pypy/doc/install.rst @@ -0,0 +1,2 @@ +Downloading and Installing PyPy +=== ___ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Remove an obscure feature that's more than a bit broken by design, the ability
Author: Maciej Fijalkowski Branch: Changeset: r64054:fa194dcff6e6 Date: 2013-05-14 03:19 +0200 http://bitbucket.org/pypy/pypy/changeset/fa194dcff6e6/ Log:Remove an obscure feature that's more than a bit broken by design, the ability to relax the check of signatures. Rationale is that if we have a non-standard graph, we should really not be able to store it anywhere. Replace a bit of unroll iterable magic with code concatanetion - ugly but works and it's actually more understandable (IMO) 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 @@ -544,11 +544,27 @@ def make_wrapper(space, callable): "NOT_RPYTHON" names = callable.api_func.argnames -argtypes_enum_ui = unrolling_iterable(enumerate(zip(callable.api_func.argtypes, -[name.startswith("w_") for name in names]))) +argtypes = callable.api_func.argtypes +is_wrapped_list = [name.startswith("w_") for name in names] fatal_value = callable.api_func.restype._defl() -def wrapper(*args): +lines = [] +for i, (argtype, is_wrapped) in enumerate(zip(argtypes, is_wrapped_list)): +if is_PyObject(argtype) and is_wrapped: +new_lines = [ +'if %(arg)s:', +'%(arg)s = from_ref(space, rffi.cast(PyObject, %(arg)s))', +'else:', +'%(arg)s = None', +] +for j in range(len(new_lines)): +new_lines[j] = new_lines[j] % {'arg': 'arg%d' % i} +lines += new_lines +middle = '\n'.join(lines) +arg_spec = ", ".join(["arg%d" % i for i in range(len(argtypes))]) + +source = py.code.Source(""" +def wrapper(%(args)s): from pypy.module.cpyext.pyobject import make_ref, from_ref from pypy.module.cpyext.pyobject import Reference retval = fatal_value @@ -556,20 +572,10 @@ try: if not we_are_translated() and DEBUG_WRAPPER: print >>sys.stderr, callable, -assert len(args) == len(callable.api_func.argtypes) -for i, (typ, is_wrapped) in argtypes_enum_ui: -arg = args[i] -if is_PyObject(typ) and is_wrapped: -if arg: -arg_conv = from_ref(space, rffi.cast(PyObject, arg)) -else: -arg_conv = None -else: -arg_conv = arg -boxed_args += (arg_conv, ) state = space.fromcache(State) +%(middle)s try: -result = callable(space, *boxed_args) +result = callable(space, %(args)s) if not we_are_translated() and DEBUG_WRAPPER: print >>sys.stderr, " DONE" except OperationError, e: @@ -591,8 +597,8 @@ if failed: error_value = callable.api_func.error_value if error_value is CANNOT_FAIL: -raise SystemError("The function '%s' was not supposed to fail" - % (callable.__name__,)) +raise SystemError("The function '%%s' was not supposed to fail" + %% (callable.__name__,)) retval = error_value elif is_PyObject(callable.api_func.restype): @@ -620,6 +626,12 @@ print str(e) pypy_debug_catch_fatal_exception() return retval +""" % {"middle": middle, "args": arg_spec}) +d = {} +d.update(locals()) +d.update(globals()) +exec source.compile() in d +wrapper = d['wrapper'] callable._always_inline_ = 'try' wrapper.__name__ = "wrapper for %r" % (callable, ) return wrapper @@ -1017,7 +1029,7 @@ export_struct(name, struct) for name, func in FUNCTIONS.iteritems(): -deco = entrypoint("cpyext", func.argtypes, name, relax=True) +deco = entrypoint("cpyext", func.argtypes, name) deco(func.get_wrapper(space)) setup_init_functions(eci, translating=True) diff --git a/rpython/annotator/description.py b/rpython/annotator/description.py --- a/rpython/annotator/description.py +++ b/rpython/annotator/description.py @@ -215,9 +215,8 @@ if len(self._cache) != 1: raise NoStandardGraph(self) [graph] = self._cache.values() -relax_sig_check = getattr(self.pyobj, "relax_sig_check", False) if (graph.signature != self.signature or -graph.defaults != self.defaults) and not relax_sig_check: +graph.defaults != self.defaults): raise NoStandardGraph(self) return graph diff --git a/rpython/annotator/test/test_annrpython.py b/rpython/annotator/test/test_annrpython.py --- a/rpython/annotator/test/test_annrpython.py +++ b/rpython/annotator/test/tes