diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 6 | ||||
-rw-r--r-- | Modules/_testcapimodule.c | 17 | ||||
-rw-r--r-- | Modules/gcmodule.c | 5 |
3 files changed, 19 insertions, 9 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index f4eb536..21b08f8 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -150,9 +150,9 @@ _DictRemover_call(PyObject *myself, PyObject *args, PyObject *kw) { DictRemoverObject *self = (DictRemoverObject *)myself; if (self->key && self->dict) { - if (-1 == PyDict_DelItem(self->dict, self->key)) - /* XXX Error context */ - PyErr_WriteUnraisable(Py_None); + if (-1 == PyDict_DelItem(self->dict, self->key)) { + _PyErr_WriteUnraisableMsg("on calling _ctypes.DictRemover", NULL); + } Py_CLEAR(self->key); Py_CLEAR(self->dict); } diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 7945f49..51e5d80 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -4985,13 +4985,24 @@ negative_refcount(PyObject *self, PyObject *Py_UNUSED(args)) static PyObject* test_write_unraisable_exc(PyObject *self, PyObject *args) { - PyObject *exc, *obj; - if (!PyArg_ParseTuple(args, "OO", &exc, &obj)) { + PyObject *exc, *err_msg, *obj; + if (!PyArg_ParseTuple(args, "OOO", &exc, &err_msg, &obj)) { return NULL; } + const char *err_msg_utf8; + if (err_msg != Py_None) { + err_msg_utf8 = PyUnicode_AsUTF8(err_msg); + if (err_msg_utf8 == NULL) { + return NULL; + } + } + else { + err_msg_utf8 = NULL; + } + PyErr_SetObject((PyObject *)Py_TYPE(exc), exc); - PyErr_WriteUnraisable(obj); + _PyErr_WriteUnraisableMsg(err_msg_utf8, obj); Py_RETURN_NONE; } diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index be9b73a..3b15c7b 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -929,9 +929,8 @@ delete_garbage(struct _gc_runtime_state *state, Py_INCREF(op); (void) clear(op); if (PyErr_Occurred()) { - PySys_WriteStderr("Exception ignored in tp_clear of " - "%.50s\n", Py_TYPE(op)->tp_name); - PyErr_WriteUnraisable(NULL); + _PyErr_WriteUnraisableMsg("in tp_clear of", + (PyObject*)Py_TYPE(op)); } Py_DECREF(op); } |