summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-06-12 11:10:24 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2016-06-12 11:10:24 (GMT)
commit0f355c0022946412ee6b7ba37ffbeb6aa8bc02a2 (patch)
tree109f696b96b493355851344a019dd742681ca106
parent96471105f4b4911961527ed616fd58056f24c685 (diff)
parent7bea2347c7e8af2c6b59e541c4039c34c7a8f6b2 (diff)
downloadcpython-0f355c0022946412ee6b7ba37ffbeb6aa8bc02a2.zip
cpython-0f355c0022946412ee6b7ba37ffbeb6aa8bc02a2.tar.gz
cpython-0f355c0022946412ee6b7ba37ffbeb6aa8bc02a2.tar.bz2
Issue #27190: Merge from 3.5
-rw-r--r--Lib/sqlite3/test/dbapi.py6
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/_sqlite/connection.c4
3 files changed, 13 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py
index 04d0479..78c27d7 100644
--- a/Lib/sqlite3/test/dbapi.py
+++ b/Lib/sqlite3/test/dbapi.py
@@ -180,6 +180,12 @@ class ConnectionTests(unittest.TestCase):
with self.assertRaises(sqlite.OperationalError):
cx.execute('insert into test(id) values(1)')
+ def CheckSameThreadErrorOnOldVersion(self):
+ if sqlite.sqlite_version_info >= (3, 3, 1):
+ self.skipTest('test needs sqlite3 versions older than 3.3.1')
+ with self.assertRaises(sqlite.NotSupportedError) as cm:
+ sqlite.connect(':memory:', check_same_thread=False)
+ self.assertEqual(str(cm.exception), 'shared connections not available')
class CursorTests(unittest.TestCase):
def setUp(self):
diff --git a/Misc/NEWS b/Misc/NEWS
index de40616..d810e12 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.6.0 alpha 2
Core and Builtins
-----------------
+- Issue #27190: Raise NotSupportedError if sqlite3 is older than 3.3.1.
+ Patch by Dave Sawyer.
+
- Issue #27286: Fixed compiling BUILD_MAP_UNPACK_WITH_CALL opcode. Calling
function with generalized unpacking (PEP 448) and conflicting keyword names
could cause undefined behavior.
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 4beed78..5349299 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -164,6 +164,10 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
#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();