From: Victor Stinner Date: Thu, 19 Dec 2013 15:44:48 +0000 (+0100) Subject: Issue #20026: Fix the sqlite module to handle correctly invalid isolation level X-Git-Tag: v2.7.8~179 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9450219b0692c9e56ddcd0dc130c995b98f9550f;p=python Issue #20026: Fix the sqlite module to handle correctly invalid isolation level (wrong type). --- diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py index 4c25f0005c..5b7759c996 100644 --- a/Lib/sqlite3/test/regression.py +++ b/Lib/sqlite3/test/regression.py @@ -313,6 +313,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") diff --git a/Misc/NEWS b/Misc/NEWS index 35da6abda6..9c9233c521 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -27,6 +27,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. diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index d89b4c1f40..59966dad5a 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -152,7 +152,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);