bpo-35504: Fix segfaults and SystemErrors when deleting certain attrs. (GH-11175)
(cherry picked from commit 842acaab1376c5c84fd5966bb6070e289880e1ca)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 5816a67..35264f5 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -1110,6 +1110,10 @@
if (future_ensure_alive(fut)) {
return -1;
}
+ if (val == NULL) {
+ PyErr_SetString(PyExc_AttributeError, "cannot delete attribute");
+ return -1;
+ }
int is_true = PyObject_IsTrue(val);
if (is_true < 0) {
@@ -1134,6 +1138,10 @@
static int
FutureObj_set_log_traceback(FutureObj *fut, PyObject *val, void *Py_UNUSED(ignored))
{
+ if (val == NULL) {
+ PyErr_SetString(PyExc_AttributeError, "cannot delete attribute");
+ return -1;
+ }
int is_true = PyObject_IsTrue(val);
if (is_true < 0) {
return -1;
@@ -2008,6 +2016,10 @@
static int
TaskObj_set_log_destroy_pending(TaskObj *task, PyObject *val, void *Py_UNUSED(ignored))
{
+ if (val == NULL) {
+ PyErr_SetString(PyExc_AttributeError, "cannot delete attribute");
+ return -1;
+ }
int is_true = PyObject_IsTrue(val);
if (is_true < 0) {
return -1;