mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
gh-92206: Improve scoping of sqlite3 register cursor helper (#92212)
This commit is contained in:
parent
628d6e8270
commit
1d4a9a45b7
3 changed files with 23 additions and 28 deletions
|
|
@ -371,32 +371,6 @@ connection_dealloc(pysqlite_Connection *self)
|
|||
Py_DECREF(tp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Registers a cursor with the connection.
|
||||
*
|
||||
* 0 => error; 1 => ok
|
||||
*/
|
||||
int pysqlite_connection_register_cursor(pysqlite_Connection* connection, PyObject* cursor)
|
||||
{
|
||||
PyObject* weakref;
|
||||
|
||||
weakref = PyWeakref_NewRef((PyObject*)cursor, NULL);
|
||||
if (!weakref) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (PyList_Append(connection->cursors, weakref) != 0) {
|
||||
Py_CLEAR(weakref);
|
||||
goto error;
|
||||
}
|
||||
|
||||
Py_DECREF(weakref);
|
||||
|
||||
return 1;
|
||||
error:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_sqlite3.Connection.cursor as pysqlite_connection_cursor
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue