Author erlendaasland
Recipients berker.peksag, erlendaasland, serhiy.storchaka
Date 2021-06-01.10:29:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Also, note that if identical SQL statements are created in multiple cursors belonging to the same connection, they will currently _not_ be added to the connection weak ref list. See the if (self->statement->in_use) in the middle of _pysqlite_query_execute(). Thus, the current code actually fails to register _all_ statements in the "all statements" weak ref list. IMO, this is yet another argument to abandon that list.

Side note: This branch is not exercised in the unit test suite. Adding the following test will cover this branch:

diff --git a/Lib/sqlite3/test/ b/Lib/sqlite3/test/
index c17f911fa1..8e53c657a6 100644
--- a/Lib/sqlite3/test/
+++ b/Lib/sqlite3/test/
@@ -526,6 +526,10 @@ def test_last_row_id_insert_o_r(self):
         self.assertEqual(results, expected)
+    def test_same_query_in_multiple_cursors(self):
+        cursors = ["select 1") for _ in range(3)]
+        for cu in cursors:
+            self.assertEqual(cu.fetchall(), [(1,)])
 class ThreadTests(unittest.TestCase):
     def setUp(self):

See bpo-43553 for sqlite3 coverage improvements.
Date User Action Args
2021-06-01 10:29:38erlendaaslandsetrecipients: + erlendaasland, berker.peksag, serhiy.storchaka
2021-06-01 10:29:38erlendaaslandsetmessageid: <>
2021-06-01 10:29:38erlendaaslandlinkissue44079 messages
2021-06-01 10:29:38erlendaaslandcreate