[pypy-commit] pypy py3.5: Fix merge and reduce diff
Author: Ronan Lamy Branch: py3.5 Changeset: r95648:59d7c3f4eb6d Date: 2019-01-16 16:26 + http://bitbucket.org/pypy/pypy/changeset/59d7c3f4eb6d/ Log:Fix merge and reduce diff diff --git a/pypy/module/__pypy__/test/test_builders.py b/pypy/module/__pypy__/test/test_builders.py --- a/pypy/module/__pypy__/test/test_builders.py +++ b/pypy/module/__pypy__/test/test_builders.py @@ -4,33 +4,32 @@ def test_simple(self): from __pypy__.builders import StringBuilder b = StringBuilder() -b.append("abc") -b.append("123") -b.append("1") +b.append(u"abc") +b.append(u"123") +b.append(u"1") s = b.build() -assert s == "abc1231" -assert type(s) is unicode +assert s == u"abc1231" assert b.build() == s -b.append("123") -assert b.build() == s + "123" +b.append(u"123") +assert b.build() == s + u"123" def test_preallocate(self): from __pypy__.builders import StringBuilder b = StringBuilder(10) -b.append("abc") -b.append("123") +b.append(u"abc") +b.append(u"123") s = b.build() -assert s == "abc123" +assert s == u"abc123" def test_append_slice(self): from __pypy__.builders import StringBuilder b = StringBuilder() -b.append_slice("abcdefgh", 2, 5) -raises(ValueError, b.append_slice, "1", 2, 1) +b.append_slice(u"abcdefgh", 2, 5) +raises(ValueError, b.append_slice, u"1", 2, 1) s = b.build() -assert s == "cde" -b.append_slice("abc", 1, 2) -assert b.build() == "cdeb" +assert s == u"cde" +b.append_slice(u"abc", 1, 2) +assert b.build() == u"cdeb" def test_stringbuilder(self): from __pypy__.builders import BytesBuilder ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: fix merge, PyUnicode_FromEncodedObject already tested in test_decode
Author: Matti Picus Branch: py3.5 Changeset: r95303:861c793cead8 Date: 2018-11-12 13:39 -0800 http://bitbucket.org/pypy/pypy/changeset/861c793cead8/ Log:fix merge, PyUnicode_FromEncodedObject already tested in test_decode diff --git a/pypy/module/cpyext/test/test_unicodeobject.py b/pypy/module/cpyext/test/test_unicodeobject.py --- a/pypy/module/cpyext/test/test_unicodeobject.py +++ b/pypy/module/cpyext/test/test_unicodeobject.py @@ -684,8 +684,6 @@ with raises_w(space, TypeError): PyUnicode_FromEncodedObject( space, space.wrap(u_text), null_charp, None) -assert space.unicode_w(PyUnicode_FromEncodedObject( -space, space.wrap(s_text), null_charp, None)) == u_text rffi.free_charp(b_text) def test_mbcs(self, space): diff --git a/pypy/module/cpyext/unicodeobject.py b/pypy/module/cpyext/unicodeobject.py --- a/pypy/module/cpyext/unicodeobject.py +++ b/pypy/module/cpyext/unicodeobject.py @@ -490,11 +490,12 @@ encoding, errors) def _pyunicode_decode(space, s, encoding, errors): -if not encoding: -# This tracks CPython 2.7, in CPython 3.4 'utf-8' is hardcoded instead -encoding = PyUnicode_GetDefaultEncoding(space) +if encoding: +w_encoding = space.newtext(rffi.charp2str(encoding)) +else: +# python 3.4 changed to this from defaultencoding +w_encoding = space.newtext('utf-8') w_str = space.newbytes(s) -w_encoding = space.newtext(rffi.charp2str(encoding)) if errors: w_errors = space.newtext(rffi.charp2str(errors)) else: @@ -530,10 +531,10 @@ All other objects, including Unicode objects, cause a TypeError to be set.""" if space.isinstance_w(w_obj, space.w_unicode): -raise oefmt(space.w_TypeError, "decoding Unicode is not supported") +raise oefmt(space.w_TypeError, "decoding str is not supported") if space.isinstance_w(w_obj, space.w_bytearray): # Python 2.x specific raise oefmt(space.w_TypeError, "decoding bytearray is not supported") -s = space.bufferstr_w(w_obj) +s = space.bytes_w(w_obj) return _pyunicode_decode(space, s, encoding, errors) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: fix merge
Author: Matti PicusBranch: py3.5 Changeset: r94242:4e6fcbd80661 Date: 2018-04-05 08:43 +0300 http://bitbucket.org/pypy/pypy/changeset/4e6fcbd80661/ Log:fix merge diff --git a/pypy/interpreter/pyparser/pyparse.py b/pypy/interpreter/pyparser/pyparse.py --- a/pypy/interpreter/pyparser/pyparse.py +++ b/pypy/interpreter/pyparser/pyparse.py @@ -148,12 +148,12 @@ raise if enc is not None: compile_info.encoding = enc +if explicit_encoding: +compile_info.flags |= consts.PyCF_FOUND_ENCODING return self._parse(textsrc, compile_info) def _parse(self, textsrc, compile_info): flags = compile_info.flags -if explicit_encoding: -flags |= consts.PyCF_FOUND_ENCODING # The tokenizer is very picky about how it wants its input. source_lines = textsrc.splitlines(True) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: fix merge, minimize diff to default
Author: Matti PicusBranch: py3.5 Changeset: r94141:fcce464367d8 Date: 2018-03-27 01:05 +0300 http://bitbucket.org/pypy/pypy/changeset/fcce464367d8/ Log:fix merge, minimize diff to default diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py --- a/pypy/module/cpyext/test/test_typeobject.py +++ b/pypy/module/cpyext/test/test_typeobject.py @@ -1,3 +1,4 @@ +import pytest from pypy.interpreter import gateway from rpython.rtyper.lltypesystem import rffi from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase @@ -6,8 +7,6 @@ from pypy.module.cpyext.pyobject import make_ref, from_ref, decref, as_pyobj from pypy.module.cpyext.typeobject import cts, PyTypeObjectPtr -import sys -import pytest class AppTestTypeObject(AppTestCpythonExtensionBase): @@ -243,6 +242,29 @@ module = self.import_module(name='foo') raises(TypeError, module.MetaType, 'other', (module.fooType,), {}) +def test_sre(self): +import sys +for m in ['_sre', 'sre_compile', 'sre_constants', 'sre_parse', 're']: +# clear out these modules +try: +del sys.modules[m] +except KeyError: +pass +module = self.import_module(name='_sre') +import re +assert re.sre_compile._sre is module +s = u"Foo " * 1000 + u"Bar" +prog = re.compile(u"Foo.*Bar") +assert prog.match(s) +m = re.search(u"xyz", u"xyzxyz") +assert m +m = re.search("xyz", "xyzxyz") +assert m +assert "groupdict" in dir(m) +re._cache.clear() +re._cache_repl.clear() +del prog, m + def test_init_error(self): module = self.import_module("foo") raises(ValueError, module.InitErrType) @@ -519,7 +541,7 @@ py_type = rffi.cast(PyTypeObjectPtr, ref) w_dict = from_ref(space, py_type.c_tp_dict) -w_name = space.newunicode(u'a') +w_name = space.newtext('a') space.setitem(w_dict, w_name, space.wrap(1)) assert space.int_w(space.getattr(w_class, w_name)) == 1 space.delitem(w_dict, w_name) @@ -549,6 +571,7 @@ def test_typeslots(self, space): assert cts.macros['Py_tp_doc'] == 56 + class AppTestSlots(AppTestCpythonExtensionBase): def setup_class(cls): AppTestCpythonExtensionBase.setup_class.im_func(cls) @@ -603,16 +626,21 @@ module = self.import_extension('foo', [ ("test_tp_getattro", "METH_VARARGS", ''' - PyObject *obj = PyTuple_GET_ITEM(args, 0); - PyObject *value = PyTuple_GET_ITEM(args, 1); + #if PY_MAJOR_VERSION > 2 + #define PyString_FromString PyUnicode_FromString + #define PyIntObject PyLongObject + #define PyInt_AsLong PyLong_AsLong + #endif + PyObject *name, *obj = PyTuple_GET_ITEM(args, 0); + PyObject *attr, *value = PyTuple_GET_ITEM(args, 1); if (!obj->ob_type->tp_getattro) { PyErr_SetString(PyExc_ValueError, "missing tp_getattro"); return NULL; } - PyObject *name = PyUnicode_FromString("attr1"); - PyObject *attr = obj->ob_type->tp_getattro(obj, name); - if (PyLong_AsLong(attr) != PyLong_AsLong(value)) + name = PyString_FromString("attr1"); + attr = obj->ob_type->tp_getattro(obj, name); + if (PyInt_AsLong(attr) != PyInt_AsLong(value)) { PyErr_SetString(PyExc_ValueError, "tp_getattro returned wrong value"); @@ -620,7 +648,7 @@ } Py_DECREF(name); Py_DECREF(attr); - name = PyUnicode_FromString("attr2"); + name = PyString_FromString("attr2"); attr = obj->ob_type->tp_getattro(obj, name); if (attr == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) { @@ -644,6 +672,9 @@ module = self.import_extension('foo', [ ("get_foo", "METH_O", ''' + #if PY_MAJOR_VERSION > 2 + #define PyString_FromString PyUnicode_FromString + #endif char* name = "foo"; PyTypeObject *tp = Py_TYPE(args); PyObject *res; @@ -651,7 +682,7 @@ res = (*tp->tp_getattr)(args, name); } else if (tp->tp_getattro != NULL) { - PyObject *w = PyUnicode_FromString(name); + PyObject *w = PyString_FromString(name); res = (*tp->tp_getattro)(args, w); Py_DECREF(w); } @@ -736,17 +767,23 @@ module =
[pypy-commit] pypy py3.5: fix merge
Author: Matti PicusBranch: py3.5 Changeset: r93688:db253d82be12 Date: 2018-01-20 19:24 +0200 http://bitbucket.org/pypy/pypy/changeset/db253d82be12/ Log:fix merge diff --git a/pypy/objspace/std/floatobject.py b/pypy/objspace/std/floatobject.py --- a/pypy/objspace/std/floatobject.py +++ b/pypy/objspace/std/floatobject.py @@ -731,8 +731,10 @@ def _hash_float(space, v): -if math.isnan(v): -return 0 +if not isfinite(v): +if isinf(v): +return HASH_INF if v > 0 else -HASH_INF +return HASH_NAN m, e = math.frexp(v) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: fix merge
Author: Matti PicusBranch: py3.5 Changeset: r93687:a7d7fd1b9931 Date: 2018-01-19 17:00 +0200 http://bitbucket.org/pypy/pypy/changeset/a7d7fd1b9931/ Log:fix merge diff --git a/pypy/interpreter/timeutils.py b/pypy/interpreter/timeutils.py --- a/pypy/interpreter/timeutils.py +++ b/pypy/interpreter/timeutils.py @@ -22,7 +22,7 @@ def timestamp_w(space, w_secs): if space.isinstance_w(w_secs, space.w_float): secs = space.float_w(w_secs) -if rfloat.isnan(secs): +if math.isnan(secs): raise oefmt(space.w_ValueError, "timestamp is nan") result_float = math.ceil(secs * SECS_TO_NS) try: diff --git a/pypy/module/cmath/interp_cmath.py b/pypy/module/cmath/interp_cmath.py --- a/pypy/module/cmath/interp_cmath.py +++ b/pypy/module/cmath/interp_cmath.py @@ -215,8 +215,8 @@ # sign would otherwise have an infinite relative tolerance. # Two infinities of the same sign are caught by the equality check # above. -if (rfloat.isinf(ax) or rfloat.isinf(ay) or -rfloat.isinf(bx) or rfloat.isinf(by)): +if (math.isinf(ax) or math.isinf(ay) or +math.isinf(bx) or math.isinf(by)): return space.w_False # # now do the regular computation diff --git a/pypy/module/cpyext/cdatetime.py b/pypy/module/cpyext/cdatetime.py --- a/pypy/module/cpyext/cdatetime.py +++ b/pypy/module/cpyext/cdatetime.py @@ -79,8 +79,6 @@ return space.is_true( space.appexec([w_obj], """(obj): from datetime import %s as datatype -if not isinstance(obj, datatype): -print datatype return isinstance(obj, datatype) """ % (type_name,))) except OperationError: diff --git a/pypy/module/math/interp_math.py b/pypy/module/math/interp_math.py --- a/pypy/module/math/interp_math.py +++ b/pypy/module/math/interp_math.py @@ -355,8 +355,8 @@ v = hi del partials[added:] if v != 0.0: -if not rfloat.isfinite(v): -if rfloat.isfinite(original): +if not math.isinf(v): +if math.isinf(original): raise oefmt(space.w_OverflowError, "intermediate overflow") if math.isinf(original): inf_sum += original @@ -473,7 +473,7 @@ # sign would otherwise have an infinite relative tolerance. # Two infinities of the same sign are caught by the equality check # above. -if rfloat.isinf(a) or rfloat.isinf(b): +if math.isinf(a) or math.isinf(b): return space.w_False # # now do the regular computation diff --git a/pypy/objspace/std/floatobject.py b/pypy/objspace/std/floatobject.py --- a/pypy/objspace/std/floatobject.py +++ b/pypy/objspace/std/floatobject.py @@ -7,7 +7,7 @@ from rpython.rlib.rarithmetic import int_between from rpython.rlib.rbigint import rbigint from rpython.rlib.rfloat import ( -DTSF_ADD_DOT_0, INFINITY, NAN, copysign, +DTSF_ADD_DOT_0, INFINITY, NAN, float_as_rbigint_ratio, formatd, isfinite) from rpython.rlib.rstring import ParseStringError from rpython.rlib.unroll import unrolling_iterable @@ -918,6 +918,6 @@ # finite x, and ndigits is not unreasonably large z = rfloat.round_double(x, ndigits, half_even=True) -if rfloat.isinf(z): +if math.isinf(z): raise oefmt(space.w_OverflowError, "overflow occurred during round") return space.newfloat(z) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: fix merge quirks, document merged branch
Author: Matti PicusBranch: py3.5 Changeset: r92886:81a7e5dcbc2d Date: 2017-10-30 19:10 +0200 http://bitbucket.org/pypy/pypy/changeset/81a7e5dcbc2d/ Log:fix merge quirks, document merged branch diff --git a/pypy/doc/whatsnew-pypy3-head.rst b/pypy/doc/whatsnew-pypy3-head.rst --- a/pypy/doc/whatsnew-pypy3-head.rst +++ b/pypy/doc/whatsnew-pypy3-head.rst @@ -11,3 +11,6 @@ .. branch: py3.5-appexec Raise if space.is_true(space.appexec()) used in app level tests, fix tests that did this + +.. branch: py3.5-mac-embedding +Download and patch dependencies when building cffi-based stdlib modules diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py --- a/rpython/rlib/rposix.py +++ b/rpython/rlib/rposix.py @@ -1864,7 +1864,7 @@ def sched_yield(): return handle_posix_error('sched_yield', c_sched_yield()) - + #___ c_chroot = external('chroot', [rffi.CCHARP], rffi.INT, diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py --- a/rpython/rlib/test/test_rposix.py +++ b/rpython/rlib/test/test_rposix.py @@ -810,11 +810,6 @@ assert isinstance(low, int) == True assert isinstance(high, int) == True assert high > low - -@rposix_requires('sched_yield') -def test_sched_yield(): -if sys.platform != 'win32': -rposix.sched_yield() @rposix_requires('sched_yield') def test_sched_yield(): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: fix merge
Author: Ronan LamyBranch: py3.5 Changeset: r92496:8b44bf979649 Date: 2017-09-29 00:18 +0200 http://bitbucket.org/pypy/pypy/changeset/8b44bf979649/ Log:fix merge 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 @@ -1340,13 +1340,13 @@ decls[pypy_decl].append(""" /* hack for https://bugs.python.org/issue29943 */ -PyAPI_FUNC(int) %s(PySliceObject *arg0, +PyAPI_FUNC(int) %s(PyObject *arg0, Signed arg1, Signed *arg2, Signed *arg3, Signed *arg4, Signed *arg5); #ifdef __GNUC__ __attribute__((__unused__)) #endif -static int PySlice_GetIndicesEx(PySliceObject *arg0, Py_ssize_t arg1, +static int PySlice_GetIndicesEx(PyObject *arg0, Py_ssize_t arg1, Py_ssize_t *arg2, Py_ssize_t *arg3, Py_ssize_t *arg4, Py_ssize_t *arg5) { return %s(arg0, arg1, arg2, arg3, diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py --- a/pypy/module/cpyext/typeobject.py +++ b/pypy/module/cpyext/typeobject.py @@ -12,15 +12,14 @@ from pypy.module.cpyext.api import ( cpython_api, cpython_struct, bootstrap_function, Py_ssize_t, slot_function, generic_cpy_call, METH_VARARGS, METH_KEYWORDS, CANNOT_FAIL, -build_type_checkers_flags, cts, parse_dir, PyObjectFields, PyTypeObject, +build_type_checkers_flags, cts, parse_dir, PyTypeObject, PyTypeObjectPtr, Py_buffer, Py_TPFLAGS_HEAPTYPE, Py_TPFLAGS_READY, Py_TPFLAGS_READYING, Py_TPFLAGS_LONG_SUBCLASS, Py_TPFLAGS_LIST_SUBCLASS, Py_TPFLAGS_TUPLE_SUBCLASS, Py_TPFLAGS_UNICODE_SUBCLASS, Py_TPFLAGS_DICT_SUBCLASS, Py_TPFLAGS_BASE_EXC_SUBCLASS, Py_TPFLAGS_TYPE_SUBCLASS, -Py_TPFLAGS_INT_SUBCLASS, Py_TPFLAGS_STRING_SUBCLASS, # change on py3 -) +Py_TPFLAGS_BYTES_SUBCLASS) from pypy.module.cpyext.cparser import CTypeSpace from pypy.module.cpyext.methodobject import (W_PyCClassMethodObject, W_PyCWrapperObject, PyCFunction_NewEx, PyCFunction, PyMethodDef, @@ -40,7 +39,6 @@ from pypy.objspace.std.typeobject import W_TypeObject, find_best_base -cts.parse_header(parse_dir / "cpyext_descrobject.h") #WARN_ABOUT_MISSING_SLOT_FUNCTIONS = False @@ -48,6 +46,7 @@ PyHeapTypeObject = cts.gettype('PyHeapTypeObject *') +cts.parse_header(parse_dir / "cpyext_descrobject.h") cts.parse_header(parse_dir / "typeslots.h") ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: fix merge issues
Author: Ronan LamyBranch: py3.5 Changeset: r92316:2db2c4a66195 Date: 2017-09-04 14:51 +0100 http://bitbucket.org/pypy/pypy/changeset/2db2c4a66195/ Log:fix merge issues diff --git a/lib-python/3/ctypes/test/test_byteswap.py b/lib-python/3/ctypes/test/test_byteswap.py --- a/lib-python/3/ctypes/test/test_byteswap.py +++ b/lib-python/3/ctypes/test/test_byteswap.py @@ -2,7 +2,6 @@ from binascii import hexlify from ctypes import * -from ctypes.test import xfail def bin(s): return hexlify(memoryview(s)).decode().upper() @@ -43,7 +42,6 @@ with self.assertRaises(AttributeError): little.z = 24 -@xfail def test_endian_short(self): if sys.byteorder == "little": self.assertIs(c_short.__ctype_le__, c_short) @@ -71,7 +69,6 @@ self.assertEqual(bin(s), "3412") self.assertEqual(s.value, 0x1234) -@xfail def test_endian_int(self): if sys.byteorder == "little": self.assertIs(c_int.__ctype_le__, c_int) @@ -100,7 +97,6 @@ self.assertEqual(bin(s), "78563412") self.assertEqual(s.value, 0x12345678) -@xfail def test_endian_longlong(self): if sys.byteorder == "little": self.assertIs(c_longlong.__ctype_le__, c_longlong) @@ -129,7 +125,6 @@ self.assertEqual(bin(s), "EFCDAB9078563412") self.assertEqual(s.value, 0x1234567890ABCDEF) -@xfail def test_endian_float(self): if sys.byteorder == "little": self.assertIs(c_float.__ctype_le__, c_float) @@ -148,7 +143,6 @@ self.assertAlmostEqual(s.value, math.pi, places=6) self.assertEqual(bin(struct.pack(">f", math.pi)), bin(s)) -@xfail def test_endian_double(self): if sys.byteorder == "little": self.assertIs(c_double.__ctype_le__, c_double) @@ -176,7 +170,6 @@ self.assertIs(c_char.__ctype_le__, c_char) self.assertIs(c_char.__ctype_be__, c_char) -@xfail def test_struct_fields_1(self): if sys.byteorder == "little": base = BigEndianStructure @@ -212,7 +205,6 @@ pass self.assertRaises(TypeError, setattr, T, "_fields_", [("x", typ)]) -@xfail def test_struct_struct(self): # nested structures with different byteorders @@ -241,7 +233,6 @@ self.assertEqual(s.point.x, 1) self.assertEqual(s.point.y, 2) -@xfail def test_struct_fields_2(self): # standard packing in struct uses no alignment. # So, we have to align using pad bytes. @@ -265,7 +256,6 @@ s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14) self.assertEqual(bin(s1), bin(s2)) -@xfail def test_unaligned_nonnative_struct_fields(self): if sys.byteorder == "little": base = BigEndianStructure diff --git a/lib_pypy/_ctypes/primitive.py b/lib_pypy/_ctypes/primitive.py --- a/lib_pypy/_ctypes/primitive.py +++ b/lib_pypy/_ctypes/primitive.py @@ -72,13 +72,13 @@ ((value >> 24) & 0xFF) def swap_8(): -return ((value & 0x00FFL) << 56) | \ - ((value & 0xFF00L) << 40) | \ - ((value & 0x00FFL) << 24) | \ - ((value & 0xFF00L) << 8) | \ - ((value & 0x00FFL) >> 8) | \ - ((value & 0xFF00L) >> 24) | \ - ((value & 0x00FFL) >> 40) | \ +return ((value & 0x00FF) << 56) | \ + ((value & 0xFF00) << 40) | \ + ((value & 0x00FF) << 24) | \ + ((value & 0xFF00) << 8) | \ + ((value & 0x00FF) >> 8) | \ + ((value & 0xFF00) >> 24) | \ + ((value & 0x00FF) >> 40) | \ ((value >> 56) & 0xFF) def swap_double_float(typ): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: fix merge
Author: Ronan LamyBranch: py3.5 Changeset: r92275:f3328bccb6b2 Date: 2017-08-28 18:28 +0100 http://bitbucket.org/pypy/pypy/changeset/f3328bccb6b2/ Log:fix merge 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 @@ -1660,7 +1660,6 @@ # overwritten with a new error of the same type error = PyErr_Occurred(space) has_new_error = (error is not None) and (error is not preexist_error) -has_result = ret is not None if not expect_null and has_new_error and has_result: raise oefmt(space.w_SystemError, "An exception was set, but function returned a " diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -739,10 +739,10 @@ # uncaught interplevel exceptions are turned into SystemError expected = "ZeroDivisionError('integer division or modulo by zero',)" exc = raises(SystemError, module.crash1) -assert exc.value[0] == expected +assert exc.value.args[0] == expected exc = raises(SystemError, module.crash2) -assert exc.value[0] == expected +assert exc.value.args[0] == expected # caught exception, api.cpython_api return value works assert module.crash3() == -1 @@ -750,7 +750,7 @@ expected = 'An exception was set, but function returned a value' # PyPy only incompatibility/extension exc = raises(SystemError, module.crash4) -assert exc.value[0] == expected +assert exc.value.args[0] == expected # An exception was set by the previous call, it can pass # cleanly through a call that doesn't check error state @@ -759,7 +759,7 @@ # clear the exception but return NULL, signalling an error expected = 'Function returned a NULL result without setting an exception' exc = raises(SystemError, module.clear, None) -assert exc.value[0] == expected +assert exc.value.args[0] == expected # Set an exception and return NULL raises(TypeError, module.set, None) @@ -770,7 +770,7 @@ # Set an exception, but return non-NULL expected = 'An exception was set, but function returned a value' exc = raises(SystemError, module.set, 1) -assert exc.value[0] == expected +assert exc.value.args[0] == expected # Clear the exception and return a value, all is OK ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: fix merge
Author: Matti PicusBranch: py3.5 Changeset: r91637:8474e41c4b75 Date: 2017-06-22 23:23 +0300 http://bitbucket.org/pypy/pypy/changeset/8474e41c4b75/ Log:fix merge diff --git a/pypy/module/cpyext/dictobject.py b/pypy/module/cpyext/dictobject.py --- a/pypy/module/cpyext/dictobject.py +++ b/pypy/module/cpyext/dictobject.py @@ -286,7 +286,6 @@ pvalue[0] = as_pyobj(space, w_value) return 1 -_frozendict_cache[space].flag_map_or_seq = 'M' @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL) def _PyDict_HasOnlyStringKeys(space, w_dict): keys_w = space.unpackiterable(w_dict) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: fix merge issues: before the merge, the code (not the tests) was
Author: Armin RigoBranch: py3.5 Changeset: r90195:0f157eedb3b2 Date: 2017-02-19 12:36 +0100 http://bitbucket.org/pypy/pypy/changeset/0f157eedb3b2/ Log:fix merge issues: before the merge, the code (not the tests) was identical in pypy2 and pypy3, so just make it identical again diff --git a/pypy/module/cppyy/converter.py b/pypy/module/cppyy/converter.py --- a/pypy/module/cppyy/converter.py +++ b/pypy/module/cppyy/converter.py @@ -771,6 +771,7 @@ for c_type, names, c_tc in type_info: class BasicConverter(ffitypes.typeid(c_type), IntTypeConverterMixin, TypeConverter): _immutable_ = True +typecode = c_tc def __init__(self, space, default): self.default = rffi.cast(self.c_type, capi.c_strtoll(space, default)) class ConstRefConverter(ConstRefNumericTypeConverterMixin, BasicConverter): diff --git a/pypy/module/cppyy/ffitypes.py b/pypy/module/cppyy/ffitypes.py --- a/pypy/module/cppyy/ffitypes.py +++ b/pypy/module/cppyy/ffitypes.py @@ -2,6 +2,7 @@ from rpython.rtyper.lltypesystem import rffi from rpython.rlib.rarithmetic import r_singlefloat, r_longfloat +from rpython.rlib.rbigint import rbigint from pypy.module._cffi_backend import newtype @@ -41,7 +42,6 @@ self.c_size_t= nt.new_primitive_type(space, 'size_t') self.c_ptrdiff_t = nt.new_primitive_type(space, 'ptrdiff_t') - class BoolTypeMixin(object): _mixin_ = True _immutable_fields_ = ['c_type', 'c_ptrtype'] @@ -49,6 +49,9 @@ c_type = rffi.UCHAR c_ptrtype = rffi.UCHARP +def _wrap_object(self, space, obj): +return space.newbool(bool(ord(rffi.cast(rffi.CHAR, obj + def _unwrap_object(self, space, w_obj): arg = space.c_int_w(w_obj) if arg != False and arg != True: @@ -56,9 +59,6 @@ "boolean value should be bool, or integer 1 or 0") return arg -def _wrap_object(self, space, obj): -return space.newbool(bool(ord(rffi.cast(rffi.CHAR, obj - def cffi_type(self, space): state = space.fromcache(State) return state.c_bool @@ -93,44 +93,44 @@ state = space.fromcache(State) return state.c_char -class ShortTypeMixin(object): +class BaseIntTypeMixin(object): +_mixin_ = True + +def _wrap_object(self, space, obj): +return space.newint(rffi.cast(rffi.INT, obj)) + +def _unwrap_object(self, space, w_obj): +return rffi.cast(self.c_type, space.c_int_w(w_obj)) + +class ShortTypeMixin(BaseIntTypeMixin): _mixin_ = True _immutable_fields_ = ['c_type', 'c_ptrtype'] c_type = rffi.SHORT c_ptrtype = rffi.SHORTP -def _unwrap_object(self, space, w_obj): -return rffi.cast(rffi.SHORT, space.int_w(w_obj)) - +class UShortTypeMixin(BaseIntTypeMixin): def cffi_type(self, space): state = space.fromcache(State) return state.c_short -class UShortTypeMixin(object): _mixin_ = True _immutable_fields_ = ['c_type', 'c_ptrtype'] c_type = rffi.USHORT c_ptrtype = rffi.USHORTP -def _unwrap_object(self, space, w_obj): -return rffi.cast(self.c_type, space.int_w(w_obj)) - +class IntTypeMixin(BaseIntTypeMixin): def cffi_type(self, space): state = space.fromcache(State) return state.c_ushort -class IntTypeMixin(object): _mixin_ = True _immutable_fields_ = ['c_type', 'c_ptrtype'] c_type = rffi.INT c_ptrtype = rffi.INTP -def _unwrap_object(self, space, w_obj): -return rffi.cast(self.c_type, space.c_int_w(w_obj)) - def cffi_type(self, space): state = space.fromcache(State) return state.c_int ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: fix merge in test_memoryobject.py
Author: Ronan LamyBranch: py3.5 Changeset: r89313:5fee3be01d9e Date: 2017-01-02 19:44 + http://bitbucket.org/pypy/pypy/changeset/5fee3be01d9e/ Log:fix merge in test_memoryobject.py 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 @@ -5,7 +5,7 @@ from pypy.module.cpyext.test.test_cpyext import AppTestCpythonExtensionBase from rpython.rlib.buffer import StringBuffer -only_pypy ="config.option.runappdirect and '__pypy__' not in sys.builtin_module_names" +only_pypy ="config.option.runappdirect and '__pypy__' not in sys.builtin_module_names" class TestMemoryViewObject(BaseApiTest): def test_fromobject(self, space, api): @@ -30,10 +30,10 @@ o = rffi.charp2str(view.c_buf) assert o == 'hello' w_mv = api.PyMemoryView_FromBuffer(view) -for f in ('format', 'itemsize', 'ndim', 'readonly', +for f in ('format', 'itemsize', 'ndim', 'readonly', 'shape', 'strides', 'suboffsets'): w_f = space.wrap(f) -assert space.eq_w(space.getattr(w_mv, w_f), +assert space.eq_w(space.getattr(w_mv, w_f), space.getattr(w_memoryview, w_f)) class AppTestPyBuffer_FillInfo(AppTestCpythonExtensionBase): @@ -87,11 +87,6 @@ assert y.shape == (10,) assert len(y) == 10 assert y[3] == 3 -s = y[3] -assert len(s) == struct.calcsize('i') -assert s == struct.pack('i', 3) -viewlen = module.test_buffer(arr) -assert viewlen == y.itemsize * len(y) def test_buffer_protocol_capi(self): foo = self.import_extension('foo', [ @@ -106,7 +101,7 @@ return NULL; vlen = view.len / view.itemsize; PyBuffer_Release(); -return PyInt_FromLong(vlen); +return PyLong_FromLong(vlen); """), ("test_buffer", "METH_VARARGS", """ @@ -114,16 +109,16 @@ PyObject* obj = PyTuple_GetItem(args, 0); PyObject* memoryview = PyMemoryView_FromObject(obj); if (memoryview == NULL) -return PyInt_FromLong(-1); +return PyLong_FromLong(-1); view = PyMemoryView_GET_BUFFER(memoryview); Py_DECREF(memoryview); -return PyInt_FromLong(view->len / view->itemsize); +return PyLong_FromLong(view->len / view->itemsize); """)]) module = self.import_module(name='buffer_test') arr = module.PyMyArray(10) ten = foo.get_len(arr) assert ten == 10 -ten = foo.get_len('1234567890') +ten = foo.get_len(b'1234567890') assert ten == 10 ten = foo.test_buffer(arr) assert ten == 10 @@ -145,15 +140,15 @@ shape, strides = get_buffer_info(arr, ['C_CONTIGUOUS']) assert strides[-1] == 8 dt1 = np.dtype( - [('a', 'b'), ('b', 'i'), - ('sub0', np.dtype('b,i')), - ('sub1', np.dtype('b,i')), - ('sub2', np.dtype('b,i')), - ('sub3', np.dtype('b,i')), - ('sub4', np.dtype('b,i')), - ('sub5', np.dtype('b,i')), - ('sub6', np.dtype('b,i')), - ('sub7', np.dtype('b,i')), + [('a', 'b'), ('b', 'i'), + ('sub0', np.dtype('b,i')), + ('sub1', np.dtype('b,i')), + ('sub2', np.dtype('b,i')), + ('sub3', np.dtype('b,i')), + ('sub4', np.dtype('b,i')), + ('sub5', np.dtype('b,i')), + ('sub6', np.dtype('b,i')), + ('sub7', np.dtype('b,i')), ('c', 'i')], ) x = np.arange(dt1.itemsize, dtype='int8').view(dt1) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit