diff options
author | Victor Stinner <vstinner@python.org> | 2021-01-27 16:39:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-27 16:39:16 (GMT) |
commit | c9b8e9c421b57acdcaf24fab0c93bc29b3ef7c67 (patch) | |
tree | f174c17b926bd968bf19ddd330524bda46e7aa8e /Modules | |
parent | eeb701adc0fc29ba803fddf133d917ff45639a00 (diff) | |
download | cpython-c9b8e9c421b57acdcaf24fab0c93bc29b3ef7c67.zip cpython-c9b8e9c421b57acdcaf24fab0c93bc29b3ef7c67.tar.gz cpython-c9b8e9c421b57acdcaf24fab0c93bc29b3ef7c67.tar.bz2 |
bpo-42979: Enhance abstract.c assertions checking slot result (GH-24352)
* bpo-42979: Enhance abstract.c assertions checking slot result
Add _Py_CheckSlotResult() function which fails with a fatal error if
a slot function succeeded with an exception set or failed with no
exception set: write the slot name, the type name and the current
exception (if an exception is set).
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 2a5b3d9..ed59c32 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -4736,6 +4736,18 @@ return_result_with_error(PyObject *self, PyObject *args) Py_RETURN_NONE; } +static PyObject* +getitem_with_error(PyObject *self, PyObject *args) +{ + PyObject *map, *key; + if (!PyArg_ParseTuple(args, "OO", &map, &key)) { + return NULL; + } + + PyErr_SetString(PyExc_ValueError, "bug"); + return PyObject_GetItem(map, key); +} + static PyObject * test_pytime_fromseconds(PyObject *self, PyObject *args) { @@ -5901,10 +5913,9 @@ static PyMethodDef TestMethods[] = { pymarshal_read_last_object_from_file, METH_VARARGS}, {"pymarshal_read_object_from_file", pymarshal_read_object_from_file, METH_VARARGS}, - {"return_null_without_error", - return_null_without_error, METH_NOARGS}, - {"return_result_with_error", - return_result_with_error, METH_NOARGS}, + {"return_null_without_error", return_null_without_error, METH_NOARGS}, + {"return_result_with_error", return_result_with_error, METH_NOARGS}, + {"getitem_with_error", getitem_with_error, METH_VARARGS}, {"PyTime_FromSeconds", test_pytime_fromseconds, METH_VARARGS}, {"PyTime_FromSecondsObject", test_pytime_fromsecondsobject, METH_VARARGS}, {"PyTime_AsSecondsDouble", test_pytime_assecondsdouble, METH_VARARGS}, |