This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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 <1622543378.87.0.342111545439.issue44079@roundup.psfhosted.org>
In-reply-to
Content
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/dbapi.py b/Lib/sqlite3/test/dbapi.py
index c17f911fa1..8e53c657a6 100644
--- a/Lib/sqlite3/test/dbapi.py
+++ b/Lib/sqlite3/test/dbapi.py
@@ -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 = [self.cx.execute("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.
History
Date User Action Args
2021-06-01 10:29:38erlendaaslandsetrecipients: + erlendaasland, berker.peksag, serhiy.storchaka
2021-06-01 10:29:38erlendaaslandsetmessageid: <1622543378.87.0.342111545439.issue44079@roundup.psfhosted.org>
2021-06-01 10:29:38erlendaaslandlinkissue44079 messages
2021-06-01 10:29:38erlendaaslandcreate