@@ -144,7 +144,6 @@ class _sqlite3.Connection "pysqlite_Connection *" "clinic_state()->ConnectionTyp
144144[clinic start generated code]*/
145145/*[clinic end generated code: output=da39a3ee5e6b4b0d input=67369db2faf80891]*/
146146
147- static int _pysqlite_drop_unused_cursor_references (pysqlite_Connection * self );
148147static void incref_callback_context (callback_context * ctx );
149148static void decref_callback_context (callback_context * ctx );
150149static void set_callback_context (callback_context * * ctx_pp ,
@@ -285,17 +284,10 @@ pysqlite_connection_init_impl(pysqlite_Connection *self, PyObject *database,
285284 goto error ;
286285 }
287286
288- /* Create lists of weak references to cursors and blobs */
289- PyObject * cursors = PyList_New (0 );
290- if (cursors == NULL ) {
291- Py_DECREF (statement_cache );
292- goto error ;
293- }
294-
287+ /* Create lists of weak references to blobs */
295288 PyObject * blobs = PyList_New (0 );
296289 if (blobs == NULL ) {
297290 Py_DECREF (statement_cache );
298- Py_DECREF (cursors );
299291 goto error ;
300292 }
301293
@@ -308,9 +300,7 @@ pysqlite_connection_init_impl(pysqlite_Connection *self, PyObject *database,
308300 self -> check_same_thread = check_same_thread ;
309301 self -> thread_ident = PyThread_get_thread_ident ();
310302 self -> statement_cache = statement_cache ;
311- self -> cursors = cursors ;
312303 self -> blobs = blobs ;
313- self -> created_cursors = 0 ;
314304 self -> row_factory = Py_NewRef (Py_None );
315305 self -> text_factory = Py_NewRef (& PyUnicode_Type );
316306 self -> trace_ctx = NULL ;
@@ -392,7 +382,6 @@ connection_traverse(PyObject *op, visitproc visit, void *arg)
392382 pysqlite_Connection * self = _pysqlite_Connection_CAST (op );
393383 Py_VISIT (Py_TYPE (self ));
394384 Py_VISIT (self -> statement_cache );
395- Py_VISIT (self -> cursors );
396385 Py_VISIT (self -> blobs );
397386 Py_VISIT (self -> row_factory );
398387 Py_VISIT (self -> text_factory );
@@ -417,7 +406,6 @@ connection_clear(PyObject *op)
417406{
418407 pysqlite_Connection * self = _pysqlite_Connection_CAST (op );
419408 Py_CLEAR (self -> statement_cache );
420- Py_CLEAR (self -> cursors );
421409 Py_CLEAR (self -> blobs );
422410 Py_CLEAR (self -> row_factory );
423411 Py_CLEAR (self -> text_factory );
@@ -562,11 +550,6 @@ pysqlite_connection_cursor_impl(pysqlite_Connection *self, PyObject *factory)
562550 return NULL ;
563551 }
564552
565- if (_pysqlite_drop_unused_cursor_references (self ) < 0 ) {
566- Py_DECREF (cursor );
567- return NULL ;
568- }
569-
570553 if (cursor && self -> row_factory != Py_None ) {
571554 Py_INCREF (self -> row_factory );
572555 Py_XSETREF (((pysqlite_Cursor * )cursor )-> row_factory , self -> row_factory );
@@ -1067,38 +1050,6 @@ final_callback(sqlite3_context *context)
10671050 PyGILState_Release (threadstate );
10681051}
10691052
1070- static int
1071- _pysqlite_drop_unused_cursor_references (pysqlite_Connection * self )
1072- {
1073- /* we only need to do this once in a while */
1074- if (self -> created_cursors ++ < 200 ) {
1075- return 0 ;
1076- }
1077-
1078- self -> created_cursors = 0 ;
1079-
1080- PyObject * new_list = PyList_New (0 );
1081- if (!new_list ) {
1082- return -1 ;
1083- }
1084-
1085- assert (PyList_CheckExact (self -> cursors ));
1086- Py_ssize_t imax = PyList_GET_SIZE (self -> cursors );
1087- for (Py_ssize_t i = 0 ; i < imax ; i ++ ) {
1088- PyObject * weakref = PyList_GET_ITEM (self -> cursors , i );
1089- if (_PyWeakref_IsDead (weakref )) {
1090- continue ;
1091- }
1092- if (PyList_Append (new_list , weakref ) != 0 ) {
1093- Py_DECREF (new_list );
1094- return -1 ;
1095- }
1096- }
1097-
1098- Py_SETREF (self -> cursors , new_list );
1099- return 0 ;
1100- }
1101-
11021053/* Allocate a UDF/callback context structure. In order to ensure that the state
11031054 * pointer always outlives the callback context, we make sure it owns a
11041055 * reference to the module itself. create_callback_context() is always called
0 commit comments