Skip to content

Commit 7bea234

Browse files
committed
Issue #27190: Raise NotSupportedError if sqlite3 is older than 3.3.1
Patch by Dave Sawyer.
1 parent c415440 commit 7bea234

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

Lib/sqlite3/test/dbapi.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ def CheckOpenUri(self):
180180
with self.assertRaises(sqlite.OperationalError):
181181
cx.execute('insert into test(id) values(1)')
182182

183+
def CheckSameThreadErrorOnOldVersion(self):
184+
if sqlite.sqlite_version_info >= (3, 3, 1):
185+
self.skipTest('test needs sqlite3 versions older than 3.3.1')
186+
with self.assertRaises(sqlite.NotSupportedError) as cm:
187+
sqlite.connect(':memory:', check_same_thread=False)
188+
self.assertEqual(str(cm.exception), 'shared connections not available')
183189

184190
class CursorTests(unittest.TestCase):
185191
def setUp(self):

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Release date: tba
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #27190: Raise NotSupportedError if sqlite3 is older than 3.3.1.
14+
Patch by Dave Sawyer.
15+
1316
- Issue #27286: Fixed compiling BUILD_MAP_UNPACK_WITH_CALL opcode. Calling
1417
function with generalized unpacking (PEP 448) and conflicting keyword names
1518
could cause undefined behavior.

Modules/_sqlite/connection.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
164164
#ifdef WITH_THREAD
165165
self->thread_ident = PyThread_get_thread_ident();
166166
#endif
167+
if (!check_same_thread && sqlite3_libversion_number() < 3003001) {
168+
PyErr_SetString(pysqlite_NotSupportedError, "shared connections not available");
169+
return -1;
170+
}
167171
self->check_same_thread = check_same_thread;
168172

169173
self->function_pinboard = PyDict_New();

0 commit comments

Comments
 (0)