Skip to content

Commit 1bbb31f

Browse files
author
Erlend E. Aasland
committed
Harden test_type_map_usage()
Don't rely on the GC dealloc'ing the implicitly created cursor executing the first select query; use one cursor, so we know that the select query won't block the subsequent delete statement.
1 parent 4ad7e99 commit 1bbb31f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Lib/sqlite3/test/regression.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,14 @@ def test_type_map_usage(self):
124124
"""
125125
SELECT = "select * from foo"
126126
con = sqlite.connect(":memory:",detect_types=sqlite.PARSE_DECLTYPES)
127-
con.execute("create table foo(bar timestamp)")
128-
con.execute("insert into foo(bar) values (?)", (datetime.datetime.now(),))
129-
con.execute(SELECT)
130-
con.execute("drop table foo")
131-
con.execute("create table foo(bar integer)")
132-
con.execute("insert into foo(bar) values (5)")
133-
con.execute(SELECT)
127+
cur = con.cursor()
128+
cur.execute("create table foo(bar timestamp)")
129+
cur.execute("insert into foo(bar) values (?)", (datetime.datetime.now(),))
130+
cur.execute(SELECT)
131+
cur.execute("drop table foo")
132+
cur.execute("create table foo(bar integer)")
133+
cur.execute("insert into foo(bar) values (5)")
134+
cur.execute(SELECT)
134135

135136
def test_bind_mutating_list(self):
136137
# Issue41662: Crash when mutate a list of parameters during iteration.

0 commit comments

Comments
 (0)