Skip to content

Commit 428f1d0

Browse files
committed
correctly catch errors
1 parent 333acdc commit 428f1d0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Modules/_curses_panel.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ insert_lop(PyCursesPanelObject *po)
288288
}
289289

290290
/* Remove the panel object from lop */
291-
static void
291+
static int
292292
remove_lop(PyCursesPanelObject *po)
293293
{
294294
list_of_panels *temp, *n;
@@ -297,19 +297,19 @@ remove_lop(PyCursesPanelObject *po)
297297
if (temp->po == po) {
298298
lop = temp->next;
299299
PyMem_Free(temp);
300-
return;
300+
return 0;
301301
}
302302
while (temp->next == NULL || temp->next->po != po) {
303303
if (temp->next == NULL) {
304304
curses_panel_notfound_error("remove_lop", NULL);
305-
return;
305+
return -1;
306306
}
307307
temp = temp->next;
308308
}
309309
n = temp->next->next;
310310
PyMem_Free(temp->next);
311311
temp->next = n;
312-
return;
312+
return 0;
313313
}
314314

315315
/* Return the panel object that corresponds to pan */
@@ -444,7 +444,9 @@ PyCursesPanel_Dealloc(PyObject *self)
444444
}
445445
if (po->wo != NULL) {
446446
Py_DECREF(po->wo);
447-
remove_lop(po);
447+
if (remove_lop(po) < 0) {
448+
PyErr_FormatUnraisable("Exception ignored in PyCursesPanel_Dealloc()");
449+
}
448450
}
449451
PyObject_Free(po);
450452
Py_DECREF(tp);

0 commit comments

Comments
 (0)