]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #20026: Fix the sqlite module to handle correctly invalid isolation level
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 19 Dec 2013 15:38:03 +0000 (16:38 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 19 Dec 2013 15:38:03 +0000 (16:38 +0100)
(wrong type).

Lib/sqlite3/test/regression.py
Misc/NEWS
Modules/_sqlite/connection.c

index b927cb3ed1857d904808eb2bc41914879a1f7030..c557ab6785d0c469ad2e1a84819f9c46aac9b19e 100644 (file)
@@ -330,6 +330,11 @@ class RegressionTests(unittest.TestCase):
             datetime.datetime(2012, 4, 4, 15, 6, 0, 123456),
         ])
 
+    def CheckInvalidIsolationLevelType(self):
+        # isolation level is a string, not an integer
+        self.assertRaises(TypeError,
+                          sqlite.connect, ":memory:", isolation_level=123)
+
 
 def suite():
     regression_suite = unittest.makeSuite(RegressionTests, "Check")
index 554f2955049e697ff6189c0a0b424ba03b055f30..dec9424cbf53c51b1f31d7d1580d973e2f8491e4 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -29,6 +29,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #20026: Fix the sqlite module to handle correctly invalid isolation
+  level (wrong type).
+
 - Issue #18829: csv.Dialect() now checks type for delimiter, escapechar and
   quotechar fields.  Original patch by Vajrasky Kok.
 
index 451ea241bd3f317060c93202eeec411bc2be6435..8cf2d6aa80c9e444afa154753a7bed7dfd3717ee 100644 (file)
@@ -109,7 +109,10 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
         Py_INCREF(isolation_level);
     }
     self->isolation_level = NULL;
-    pysqlite_connection_set_isolation_level(self, isolation_level);
+    if (pysqlite_connection_set_isolation_level(self, isolation_level) < 0) {
+        Py_DECREF(isolation_level);
+        return -1;
+    }
     Py_DECREF(isolation_level);
 
     self->statement_cache = (pysqlite_Cache*)PyObject_CallFunction((PyObject*)&pysqlite_CacheType, "Oi", self, cached_statements);