[pypy-commit] pypy cpyext-ext: Un-skip some appdirect tests: TP_FLAGS_DEFAULT is really really needed for all types since Python 2.2...
amauryfa
pypy.commits at gmail.com
Tue Dec 29 20:30:35 EST 2015
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: cpyext-ext
Changeset: r81496:8520e2b4b038
Date: 2015-12-30 01:36 +0100
http://bitbucket.org/pypy/pypy/changeset/8520e2b4b038/
Log: Un-skip some appdirect tests: TP_FLAGS_DEFAULT is really really
needed for all types since Python 2.2...
diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py
--- a/pypy/module/cpyext/slotdefs.py
+++ b/pypy/module/cpyext/slotdefs.py
@@ -92,7 +92,7 @@
res = generic_cpy_call(space, func_inquiry, w_self)
res = rffi.cast(lltype.Signed, res)
if res == -1:
- space.fromcache(State).check_and_raise_exception()
+ space.fromcache(State).check_and_raise_exception(always=True)
return space.wrap(bool(res))
def wrap_getattr(space, w_self, w_args, func):
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
@@ -502,12 +502,11 @@
assert module.tp_str(C()) == "text"
def test_mp_ass_subscript(self):
- if self.runappdirect:
- py.test.xfail('segfault')
module = self.import_extension('foo', [
("new_obj", "METH_NOARGS",
'''
PyObject *obj;
+ Foo_Type.tp_flags = Py_TPFLAGS_DEFAULT;
Foo_Type.tp_as_mapping = &tp_as_mapping;
tp_as_mapping.mp_ass_subscript = mp_ass_subscript;
if (PyType_Ready(&Foo_Type) < 0) return NULL;
@@ -537,12 +536,11 @@
assert res is None
def test_sq_contains(self):
- if self.runappdirect:
- py.test.xfail('segfault')
module = self.import_extension('foo', [
("new_obj", "METH_NOARGS",
'''
PyObject *obj;
+ Foo_Type.tp_flags = Py_TPFLAGS_DEFAULT;
Foo_Type.tp_as_sequence = &tp_as_sequence;
tp_as_sequence.sq_contains = sq_contains;
if (PyType_Ready(&Foo_Type) < 0) return NULL;
@@ -596,18 +594,17 @@
raises(StopIteration, module.tp_iternext, it)
def test_bool(self):
- if self.runappdirect:
- py.test.xfail('segfault')
module = self.import_extension('foo', [
("newInt", "METH_VARARGS",
"""
IntLikeObject *intObj;
- long intval;
+ int intval;
PyObject *name;
if (!PyArg_ParseTuple(args, "i", &intval))
return NULL;
+ IntLike_Type.tp_flags |= Py_TPFLAGS_DEFAULT;
IntLike_Type.tp_as_number = &intlike_as_number;
intlike_as_number.nb_nonzero = intlike_nb_nonzero;
if (PyType_Ready(&IntLike_Type) < 0) return NULL;
@@ -633,6 +630,7 @@
PyErr_SetNone(PyExc_ValueError);
return -1;
}
+ /* Returning -1 should be for exceptions only! */
return v->value;
}
@@ -646,12 +644,10 @@
""")
assert not bool(module.newInt(0))
assert bool(module.newInt(1))
- assert bool(module.newInt(-1))
+ raises(SystemError, bool, module.newInt(-1))
raises(ValueError, bool, module.newInt(-42))
def test_binaryfunc(self):
- if self.runappdirect:
- py.test.xfail('segfault')
module = self.import_extension('foo', [
("newInt", "METH_VARARGS",
"""
@@ -662,7 +658,7 @@
return NULL;
IntLike_Type.tp_as_number = &intlike_as_number;
- IntLike_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES;
+ IntLike_Type.tp_flags |= Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES;
intlike_as_number.nb_add = intlike_nb_add;
if (PyType_Ready(&IntLike_Type) < 0) return NULL;
intObj = PyObject_New(IntLikeObject, &IntLike_Type);
@@ -681,7 +677,7 @@
if (!PyArg_ParseTuple(args, "l", &intval))
return NULL;
- IntLike_Type_NoOp.tp_flags |= Py_TPFLAGS_CHECKTYPES;
+ IntLike_Type_NoOp.tp_flags |= Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES;
if (PyType_Ready(&IntLike_Type_NoOp) < 0) return NULL;
intObjNoOp = PyObject_New(IntLikeObjectNoOp, &IntLike_Type_NoOp);
if (!intObjNoOp) {
More information about the pypy-commit
mailing list