Author: Ronan Lamy <ronan.l...@gmail.com> Branch: py3k Changeset: r86200:f2a780e47063 Date: 2016-08-15 16:43 +0100 http://bitbucket.org/pypy/pypy/changeset/f2a780e47063/
Log: hg merge 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 @@ -128,3 +128,19 @@ .. branch: cpyext-realloc Implement PyObject_Realloc + +.. branch: inline-blocks + +Improve a little bit the readability of the generated C code + +.. branch: improve-vmprof-testing + +Improved vmprof support: now tries hard to not miss any Python-level +frame in the captured stacks, even if there is the metainterp or +blackhole interp involved. Also fix the stacklet (greenlet) support. + +.. branch: py2-mappingproxy + +``type.__dict__`` now returns a ``dict_proxy`` object, like on CPython. +Previously it returned what looked like a regular dict object (but it +was already read-only). diff --git a/pypy/module/_cffi_backend/cdataobj.py b/pypy/module/_cffi_backend/cdataobj.py --- a/pypy/module/_cffi_backend/cdataobj.py +++ b/pypy/module/_cffi_backend/cdataobj.py @@ -310,11 +310,15 @@ self.ctype.name, ct.name) # itemsize = ct.ctitem.size - if itemsize <= 0: - itemsize = 1 with self as ptr1, w_other as ptr2: diff = (rffi.cast(lltype.Signed, ptr1) - - rffi.cast(lltype.Signed, ptr2)) // itemsize + rffi.cast(lltype.Signed, ptr2)) + if itemsize > 1: + if diff % itemsize: + raise oefmt(space.w_ValueError, + "pointer subtraction: the distance between the two " + "pointers is not a multiple of the item size") + diff //= itemsize return space.wrap(diff) # return self._add_or_sub(w_other, -1) diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py --- a/pypy/module/_cffi_backend/test/_backend_test_c.py +++ b/pypy/module/_cffi_backend/test/_backend_test_c.py @@ -576,6 +576,19 @@ e = py.test.raises(TypeError, "q - a") assert str(e.value) == "cannot subtract cdata 'short *' and cdata 'int *'" +def test_ptr_sub_unaligned(): + BInt = new_primitive_type("int") + BIntPtr = new_pointer_type(BInt) + a = cast(BIntPtr, 1240) + for bi in range(1430, 1438): + b = cast(BIntPtr, bi) + if ((bi - 1240) % size_of_int()) == 0: + assert b - a == (bi - 1240) // size_of_int() + assert a - b == (1240 - bi) // size_of_int() + else: + py.test.raises(ValueError, "b - a") + py.test.raises(ValueError, "a - b") + def test_cast_primitive_from_cdata(): p = new_primitive_type("int") n = cast(p, cast(p, -42)) diff --git a/pypy/module/cpyext/include/Python.h b/pypy/module/cpyext/include/Python.h --- a/pypy/module/cpyext/include/Python.h +++ b/pypy/module/cpyext/include/Python.h @@ -2,6 +2,9 @@ #define Py_PYTHON_H /* Compat stuff */ +#ifdef __GNUC__ +#define _GNU_SOURCE 1 +#endif #ifndef _WIN32 # include <inttypes.h> # include <stdint.h> @@ -52,7 +55,6 @@ #ifndef DL_IMPORT # define DL_IMPORT(RTYPE) RTYPE #endif - #include <stdlib.h> #ifndef _WIN32 diff --git a/requirements.txt b/requirements.txt --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ +cffi>=1.4.0 + # hypothesis is used for test generation on untranslated tests hypothesis enum34>=1.1.2 diff --git a/rpython/doc/arm.rst b/rpython/doc/arm.rst --- a/rpython/doc/arm.rst +++ b/rpython/doc/arm.rst @@ -148,7 +148,7 @@ :: - pypy ~/path_to_pypy_checkout/rpython/bin/rpython -O1 --platform=arm target.py + pypy ~/path_to_pypy_checkout/rpython/bin/rpython -O2 --platform=arm target.py If everything worked correctly this should yield an ARM binary. Running this binary in the ARM chroot or on an ARM device should produce the output ``"Hello World"``. diff --git a/rpython/rlib/rweakref.py b/rpython/rlib/rweakref.py --- a/rpython/rlib/rweakref.py +++ b/rpython/rlib/rweakref.py @@ -142,7 +142,7 @@ def compute_result_annotation(self, s_keyclass, s_valueclass): assert s_keyclass.is_constant() - s_key = self.bookkeeper.immutablevalue(s_keyclass.const()) + s_key = self.bookkeeper.valueoftype(s_keyclass.const) return SomeWeakValueDict( s_key, _getclassdef(s_valueclass)) @@ -158,7 +158,7 @@ bk = self.bookkeeper x = self.instance return SomeWeakValueDict( - bk.immutablevalue(x._keyclass()), + bk.valueoftype(x._keyclass), bk.getuniqueclassdef(x._valueclass)) def _getclassdef(s_instance): diff --git a/rpython/rlib/test/test_rweakvaldict.py b/rpython/rlib/test/test_rweakvaldict.py --- a/rpython/rlib/test/test_rweakvaldict.py +++ b/rpython/rlib/test/test_rweakvaldict.py @@ -180,3 +180,36 @@ RWeakValueDictionary(str, X).get("foobar") RWeakValueDictionary(int, Y).get(42) interpret(g, []) + +def test_key_instance(): + class K(object): + pass + keys = [K(), K(), K()] + + def g(d): + assert d.get(keys[3]) is None + x1 = X(); x2 = X(); x3 = X() + d.set(keys[0], x1) + d.set(keys[1], x2) + d.set(keys[2], x3) + assert d.get(keys[0]) is x1 + assert d.get(keys[1]) is x2 + assert d.get(keys[2]) is x3 + assert d.get(keys[3]) is None + return x1, x3 # x2 dies + def f(): + keys.append(K()) + d = RWeakValueDictionary(K, X) + x1, x3 = g(d) + rgc.collect(); rgc.collect() + assert d.get(keys[0]) is x1 + assert d.get(keys[1]) is None + assert d.get(keys[2]) is x3 + assert d.get(keys[3]) is None + d.set(keys[0], None) + assert d.get(keys[0]) is None + assert d.get(keys[1]) is None + assert d.get(keys[2]) is x3 + assert d.get(keys[3]) is None + f() + interpret(f, []) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit