[Python-checkins] cpython (merge 3.5 -> default): Issue #27190: Merge from 3.5

berker.peksag python-checkins at python.org
Sun Jun 12 07:10:23 EDT 2016


https://hg.python.org/cpython/rev/4502cff170c2
changeset:   101941:4502cff170c2
parent:      101939:187b2bc0fe26
parent:      101940:12bf71b9f1cd
user:        Berker Peksag <berker.peksag at gmail.com>
date:        Sun Jun 12 14:10:24 2016 +0300
summary:
  Issue #27190: Merge from 3.5

files:
  Lib/sqlite3/test/dbapi.py    |  6 ++++++
  Misc/NEWS                    |  3 +++
  Modules/_sqlite/connection.c |  4 ++++
  3 files changed, 13 insertions(+), 0 deletions(-)


diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py
--- a/Lib/sqlite3/test/dbapi.py
+++ b/Lib/sqlite3/test/dbapi.py
@@ -180,6 +180,12 @@
             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
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 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
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -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();

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list