Skip to content

Commit

Permalink
Do not allow exceptions in Cursor destructor (#585)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkleehammer committed Apr 11, 2023
1 parent 6b107a2 commit 5ab74b3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,10 @@ static void Cursor_dealloc(Cursor* cursor)
if (Cursor_Validate((PyObject*)cursor, CURSOR_REQUIRE_CNXN))
{
closeimpl(cursor);
if (PyErr_Occurred()) {
// We are in a Cursor destructor (__del__) and should not raise exceptions.
PyErr_Clear();
}
}
Py_XDECREF(cursor->inputsizes);
PyObject_Del(cursor);
Expand Down

0 comments on commit 5ab74b3

Please # to comment.