diff -r 3a57eafd8401 Lib/sqlite3/test/dbapi.py --- a/Lib/sqlite3/test/dbapi.py Tue May 24 09:15:14 2016 +0300 +++ b/Lib/sqlite3/test/dbapi.py Fri Jun 03 12:09:15 2016 -0700 @@ -180,6 +180,11 @@ with self.assertRaises(sqlite.OperationalError): cx.execute('insert into test(id) values(1)') + def CheckSameThreadErrorOnOldVersion(self): + if sqlite.sqlite_version_info < (3, 3, 1): + with self.assertRaises(sqlite.NotSupportedError): + sqlite.connect(':memory:', check_same_thread=False) + class CursorTests(unittest.TestCase): def setUp(self): diff -r 3a57eafd8401 Modules/_sqlite/connection.c --- a/Modules/_sqlite/connection.c Tue May 24 09:15:14 2016 +0300 +++ b/Modules/_sqlite/connection.c Fri Jun 03 12:09:15 2016 -0700 @@ -164,6 +164,10 @@ #ifdef WITH_THREAD self->thread_ident = PyThread_get_thread_ident(); #endif + if (!check_same_thread && sqlite3_libversion_number() < 3003001) { + PyErr_SetString(pysqlite_NotSupportedError, "Shared connections not available"); + return -1; + } self->check_same_thread = check_same_thread; self->function_pinboard = PyDict_New();