be extra careful with a borrowed reference when the GIL could be released (closes #8578)

This commit is contained in:
Benjamin Peterson 2011-05-31 21:31:37 -05:00
parent 2e3a38a774
commit 5c2b09e856

View file

@ -200,11 +200,13 @@ void pysqlite_do_all_statements(pysqlite_Connection* self, int action, int reset
weakref = PyList_GetItem(self->statements, i);
statement = PyWeakref_GetObject(weakref);
if (statement != Py_None) {
Py_INCREF(statement);
if (action == ACTION_RESET) {
(void)pysqlite_statement_reset((pysqlite_Statement*)statement);
} else {
(void)pysqlite_statement_finalize((pysqlite_Statement*)statement);
}
Py_DECREF(statement);
}
}