Author: David Schneider <david.schnei...@picle.org> Branch: emit-call-arm Changeset: r64575:3b08d6880292 Date: 2013-05-27 09:22 +0200 http://bitbucket.org/pypy/pypy/changeset/3b08d6880292/
Log: merge default diff --git a/lib_pypy/_ctypes/structure.py b/lib_pypy/_ctypes/structure.py --- a/lib_pypy/_ctypes/structure.py +++ b/lib_pypy/_ctypes/structure.py @@ -166,8 +166,7 @@ if self is StructOrUnion: return if '_fields_' not in self.__dict__: - self._fields_ = [] - _set_shape(self, [], self._is_union) + self._fields_ = [] # As a side-effet, this also sets the ffishape. __setattr__ = struct_setattr diff --git a/pypy/doc/cppyy.rst b/pypy/doc/cppyy.rst --- a/pypy/doc/cppyy.rst +++ b/pypy/doc/cppyy.rst @@ -163,6 +163,9 @@ $ genreflex MyClass.h $ g++ -fPIC -rdynamic -O2 -shared -I$REFLEXHOME/include MyClass_rflx.cpp -o libMyClassDict.so -L$REFLEXHOME/lib -lReflex +Next, make sure that the library can be found through the dynamic lookup path +(the ``LD_LIBRARY_PATH`` environment variable on Linux, ``PATH`` on Windows), +for example by adding ".". Now you're ready to use the bindings. Since the bindings are designed to look pythonistic, it should be straightforward:: diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py --- a/pypy/goal/targetpypystandalone.py +++ b/pypy/goal/targetpypystandalone.py @@ -124,14 +124,21 @@ @entrypoint('main', [], c_name='pypy_init_threads') def pypy_init_threads(): - if space.config.objspace.usemodules.thread: - os_thread.setup_threads(space) - rffi.aroundstate.before() + if not space.config.objspace.usemodules.thread: + return + os_thread.setup_threads(space) + rffi.aroundstate.before() @entrypoint('main', [], c_name='pypy_thread_attach') def pypy_thread_attach(): - if space.config.objspace.usemodules.thread: - rthread.gc_thread_start() + if not space.config.objspace.usemodules.thread: + return + os_thread.setup_threads(space) + os_thread.bootstrapper.acquire(space, None, None) + rthread.gc_thread_start() + os_thread.bootstrapper.nbthreads += 1 + os_thread.bootstrapper.release() + rffi.aroundstate.before() w_globals = space.newdict() space.setitem(w_globals, space.wrap('__builtins__'), diff --git a/pypy/module/_io/interp_iobase.py b/pypy/module/_io/interp_iobase.py --- a/pypy/module/_io/interp_iobase.py +++ b/pypy/module/_io/interp_iobase.py @@ -16,6 +16,11 @@ else: return space.int_w(w_size) +def unsupported(space, message): + w_exc = space.getattr(space.getbuiltinmodule('_io'), + space.wrap('UnsupportedOperation')) + return OperationError(w_exc, space.wrap(message)) + # May be called with any object def check_readable_w(space, w_obj): if not space.is_true(space.call_method(w_obj, 'readable')): @@ -86,6 +91,9 @@ # attribute as returned by whatever subclass. return self.__IOBase_closed + def _unsupportedoperation(self, space, message): + raise unsupported(space, message) + def _check_closed(self, space, message=None): if message is None: message = "I/O operation on closed file" @@ -111,9 +119,18 @@ space.w_ValueError, space.wrap("I/O operation on closed file")) + def seek_w(self, space, w_offset, w_whence=None): + self._unsupportedoperation(space, "seek") + def tell_w(self, space): return space.call_method(self, "seek", space.wrap(0), space.wrap(1)) + def truncate_w(self, space, w_size=None): + self._unsupportedoperation(space, "truncate") + + def fileno_w(self, space): + self._unsupportedoperation(space, "fileno") + def enter_w(self, space): self._check_closed(space) return space.wrap(self) @@ -248,11 +265,15 @@ next = interp2app(W_IOBase.next_w), close = interp2app(W_IOBase.close_w), flush = interp2app(W_IOBase.flush_w), + seek = interp2app(W_IOBase.seek_w), tell = interp2app(W_IOBase.tell_w), + truncate = interp2app(W_IOBase.truncate_w), + fileno = interp2app(W_IOBase.fileno_w), isatty = interp2app(W_IOBase.isatty_w), readable = interp2app(W_IOBase.readable_w), writable = interp2app(W_IOBase.writable_w), seekable = interp2app(W_IOBase.seekable_w), + _checkReadable = interp2app(check_readable_w), _checkWritable = interp2app(check_writable_w), _checkSeekable = interp2app(check_seekable_w), diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py --- a/pypy/module/_io/interp_textio.py +++ b/pypy/module/_io/interp_textio.py @@ -196,11 +196,6 @@ def __init__(self, space): W_IOBase.__init__(self, space) - def _unsupportedoperation(self, space, message): - w_exc = space.getattr(space.getbuiltinmodule('_io'), - space.wrap('UnsupportedOperation')) - raise OperationError(w_exc, space.wrap(message)) - def read_w(self, space, w_size=None): self._unsupportedoperation(space, "read") diff --git a/pypy/module/_io/test/test_io.py b/pypy/module/_io/test/test_io.py --- a/pypy/module/_io/test/test_io.py +++ b/pypy/module/_io/test/test_io.py @@ -43,6 +43,13 @@ import _io e = _io.UnsupportedOperation("seek") + def test_default_implementations(self): + import _io + file = _io._IOBase() + raises(_io.UnsupportedOperation, file.seek, 0, 1) + raises(_io.UnsupportedOperation, file.fileno) + raises(_io.UnsupportedOperation, file.truncate) + def test_blockingerror(self): import _io try: diff --git a/pypy/module/_io/test/test_textio.py b/pypy/module/_io/test/test_textio.py --- a/pypy/module/_io/test/test_textio.py +++ b/pypy/module/_io/test/test_textio.py @@ -26,6 +26,14 @@ assert t.readable() assert t.seekable() + def test_default_implementations(self): + import _io + file = _io._TextIOBase() + raises(_io.UnsupportedOperation, file.read) + raises(_io.UnsupportedOperation, file.seek, 0) + raises(_io.UnsupportedOperation, file.readline) + raises(_io.UnsupportedOperation, file.detach) + def test_unreadable(self): import _io class UnReadable(_io.BytesIO): diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/micronumpy/compile.py --- a/pypy/module/micronumpy/compile.py +++ b/pypy/module/micronumpy/compile.py @@ -46,11 +46,11 @@ self.name = name class FakeSpace(object): - w_ValueError = "ValueError" - w_TypeError = "TypeError" - w_IndexError = "IndexError" - w_OverflowError = "OverflowError" - w_NotImplementedError = "NotImplementedError" + w_ValueError = W_TypeObject("ValueError") + w_TypeError = W_TypeObject("TypeError") + w_IndexError = W_TypeObject("IndexError") + w_OverflowError = W_TypeObject("OverflowError") + w_NotImplementedError = W_TypeObject("NotImplementedError") w_None = None w_bool = W_TypeObject("bool") diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/micronumpy/interp_boxes.py --- a/pypy/module/micronumpy/interp_boxes.py +++ b/pypy/module/micronumpy/interp_boxes.py @@ -254,6 +254,8 @@ descr__new__, _get_dtype = new_dtype_getter("float64") class W_FlexibleBox(W_GenericBox): + _attrs_ = ['ofs', 'dtype', 'arr'] + _immutable_fields_ = ['ofs'] def __init__(self, arr, ofs, dtype): self.arr = arr # we have to keep array alive self.ofs = ofs diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py --- a/pypy/module/micronumpy/test/test_dtypes.py +++ b/pypy/module/micronumpy/test/test_dtypes.py @@ -275,7 +275,7 @@ from numpypy import array, dtype from cPickle import loads, dumps a = array([1,2,3]) - if self.ptr_size == 8: + if self.ptr_size == 8: assert a.dtype.__reduce__() == (dtype, ('i8', 0, 1), (3, '<', None, None, None, -1, -1, 0)) else: assert a.dtype.__reduce__() == (dtype, ('i4', 0, 1), (3, '<', None, None, None, -1, -1, 0)) @@ -786,7 +786,7 @@ def test_create_subarrays(self): from numpypy import dtype - d = dtype([("x", "float", (2,)), ("y", "int", (2,))]) + d = dtype([("x", "float", (2,)), ("y", "int64", (2,))]) assert d.itemsize == 32 assert d.name == "void256" keys = d.fields.keys() 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 @@ -2715,7 +2715,7 @@ a[0]["x"][0] = 200 assert a[0]["x"][0] == 200 - d = dtype([("x", "int", (2, 3))]) + d = dtype([("x", "int64", (2, 3))]) a = array([([[1, 2, 3], [4, 5, 6]],)], dtype=d) assert a[0]["x"].dtype == dtype("int64") @@ -2735,7 +2735,7 @@ def test_multidim_subarray(self): from numpypy import dtype, array - d = dtype([("x", "int", (2, 3))]) + d = dtype([("x", "int64", (2, 3))]) a = array([([[1, 2, 3], [4, 5, 6]],)], dtype=d) assert a[0]["x"].dtype == dtype("int64") 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 @@ -1704,28 +1704,11 @@ T = lltype.Char def _coerce(self, space, arr, ofs, dtype, w_items, shape): - items_w = space.fixedview(w_items) - for i in range(len(items_w)): - subdtype = dtype.subdtype - itemtype = subdtype.itemtype - if space.len_w(shape) <= 1: - w_box = itemtype.coerce(space, dtype.subdtype, items_w[i]) - itemtype.store(arr, 0, ofs, w_box) - ofs += itemtype.get_element_size() - else: - size = 1 - for dimension in shape[1:]: - size *= dimension - size *= itemtype.get_element_size() - for w_item in items_w: - self._coerce(space, arr, ofs, dtype, w_items, shape[1:]) - ofs += size - return arr - - def _coerce(self, space, arr, ofs, dtype, w_items, shape): # TODO: Make sure the shape and the array match + from interp_dtype import W_Dtype items_w = space.fixedview(w_items) subdtype = dtype.subdtype + assert isinstance(subdtype, W_Dtype) itemtype = subdtype.itemtype if len(shape) <= 1: for i in range(len(items_w)): diff --git a/pypy/module/pypyjit/test_pypy_c/test_array.py b/pypy/module/pypyjit/test_pypy_c/test_array.py --- a/pypy/module/pypyjit/test_pypy_c/test_array.py +++ b/pypy/module/pypyjit/test_pypy_c/test_array.py @@ -105,7 +105,6 @@ assert loop.match(""" i10 = int_lt(i6, 1000) guard_true(i10, descr=...) - guard_not_invalidated(descr=...) i11 = int_lt(i6, i7) guard_true(i11, descr=...) f13 = getarrayitem_raw(i8, i6, descr=<ArrayF 8>) @@ -142,7 +141,6 @@ assert loop.match(""" i10 = int_lt(i6, 1000) guard_true(i10, descr=...) - guard_not_invalidated(descr=...) i11 = int_lt(i6, i7) guard_true(i11, descr=...) i13 = getarrayitem_raw(i8, i6, descr=<Array. 4>) diff --git a/pypy/module/pypyjit/test_pypy_c/test_call.py b/pypy/module/pypyjit/test_pypy_c/test_call.py --- a/pypy/module/pypyjit/test_pypy_c/test_call.py +++ b/pypy/module/pypyjit/test_pypy_c/test_call.py @@ -339,7 +339,6 @@ loop, = log.loops_by_filename(self.filepath) # the int strategy is used here assert loop.match_by_id('append', """ - guard_not_invalidated(descr=...) i13 = getfield_gc(p8, descr=<FieldS list.length .*>) i15 = int_add(i13, 1) # Will be killed by the backend @@ -487,7 +486,6 @@ assert loop.match(""" i2 = int_lt(i0, i1) guard_true(i2, descr=...) - guard_not_invalidated(descr=...) i3 = force_token() i4 = int_add(i0, 1) --TICK-- @@ -587,6 +585,7 @@ """, [1000]) loop, = log.loops_by_id('call') assert loop.match_by_id('call', ''' + guard_not_invalidated(descr=...) i1 = force_token() ''') diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_structures.py b/pypy/module/test_lib_pypy/ctypes_tests/test_structures.py --- a/pypy/module/test_lib_pypy/ctypes_tests/test_structures.py +++ b/pypy/module/test_lib_pypy/ctypes_tests/test_structures.py @@ -239,6 +239,9 @@ pass pos = POSITION(1, 2) assert (pos.x, pos.y) == (1, 2) + # Try a second time, result may be different (cf. issue1498) + pos = POSITION(1, 2) + assert (pos.x, pos.y) == (1, 2) def test_invalid_field_types(self): diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py --- a/pypy/tool/release/package.py +++ b/pypy/tool/release/package.py @@ -73,6 +73,11 @@ rename_pypy_c += '.exe' binaries = [(pypy_c, rename_pypy_c)] # + builddir = udir.ensure("build", dir=True) + pypydir = builddir.ensure(name, dir=True) + includedir = basedir.join('include') + pypydir.ensure('include', dir=True) + if sys.platform == 'win32': #Don't include a mscvrXX.dll, users should get their own. #Instructions are provided on the website. @@ -85,12 +90,22 @@ p = pypy_c.dirpath().join(extra) if not p.check(): p = py.path.local.sysfind(extra) - assert p, "%s not found" % (extra,) + if not p: + print "%s not found, expect trouble if this is a shared build" % (extra,) + continue print "Picking %s" % p binaries.append((p, p.basename)) - # - builddir = udir.ensure("build", dir=True) - pypydir = builddir.ensure(name, dir=True) + if pypy_c.dirpath().join("libpypy-c.lib").check(): + shutil.copyfile(str(pypy_c.dirpath().join("libpypy-c.lib")), + str(pypydir.join('include/python27.lib'))) + print "Picking %s as %s" % (pypy_c.dirpath().join("libpypy-c.lib"), + pypydir.join('include/python27.lib')) + else: + pass + # XXX users will complain that they cannot compile cpyext + # modules for windows, has the lib moved or are there no + # exported functions in the dll so no import library is created? + # Careful: to copy lib_pypy, copying just the svn-tracked files # would not be enough: there are also ctypes_config_cache/_*_cache.py. shutil.copytree(str(basedir.join('lib-python').join(STDLIB_VER)), @@ -102,15 +117,10 @@ '*.c', '*.o')) for file in ['LICENSE', 'README.rst']: shutil.copy(str(basedir.join(file)), str(pypydir)) - pypydir.ensure('include', dir=True) - if sys.platform == 'win32': - shutil.copyfile(str(pypy_c.dirpath().join("libpypy-c.lib")), - str(pypydir.join('include/python27.lib'))) - # we want to put there all *.h and *.inl from trunk/include - # and from pypy/_interfaces - includedir = basedir.join('include') headers = includedir.listdir('*.h') + includedir.listdir('*.inl') for n in headers: + # we want to put there all *.h and *.inl from trunk/include + # and from pypy/_interfaces shutil.copy(str(n), str(pypydir.join('include'))) # spdir = pypydir.ensure('site-packages', dir=True) diff --git a/rpython/jit/metainterp/compile.py b/rpython/jit/metainterp/compile.py --- a/rpython/jit/metainterp/compile.py +++ b/rpython/jit/metainterp/compile.py @@ -85,7 +85,7 @@ # exported_state is clear by optimizeopt when the short preamble is # constrcucted. if that did not happen the label should not show up # in a trace that will be used - assert descr.exported_state is None + assert descr.exported_state is None if not we_are_translated(): op._descr_wref = weakref.ref(op._descr) op.cleardescr() # clear reference to prevent the history.Stats @@ -819,7 +819,7 @@ # The history contains new operations to attach as the code for the # failure of 'resumekey.guard_op'. - # + # # Attempt to use optimize_bridge(). This may return None in case # it does not work -- i.e. none of the existing old_loop_tokens match. new_trace = create_empty_loop(metainterp) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit