aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-01-27 17:39:16 +0100
committerGitHub <noreply@github.com>2021-01-27 16:39:16 +0000
commitc9b8e9c421b57acdcaf24fab0c93bc29b3ef7c67 (patch)
treef174c17b926bd968bf19ddd330524bda46e7aa8e /Modules
parentbpo-42979: _zoneinfo exec function checks for PyDateTime_IMPORT failure (GH-2... (diff)
downloadcpython-c9b8e9c421b57acdcaf24fab0c93bc29b3ef7c67.tar.gz
cpython-c9b8e9c421b57acdcaf24fab0c93bc29b3ef7c67.tar.bz2
cpython-c9b8e9c421b57acdcaf24fab0c93bc29b3ef7c67.zip
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.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 2a5b3d9c50b..ed59c32e9c5 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},