[Python-checkins] cpython (3.3): Issue #20026: Fix the sqlite module to handle correctly invalid isolation level
victor.stinner
python-checkins at python.org
Thu Dec 19 16:41:58 CET 2013
http://hg.python.org/cpython/rev/11a161cf0e5d
changeset: 88062:11a161cf0e5d
branch: 3.3
parent: 88059:52d03fbdf67a
user: Victor Stinner <victor.stinner at gmail.com>
date: Thu Dec 19 16:38:03 2013 +0100
summary:
Issue #20026: Fix the sqlite module to handle correctly invalid isolation level
(wrong type).
files:
Lib/sqlite3/test/regression.py | 5 +++++
Misc/NEWS | 3 +++
Modules/_sqlite/connection.c | 5 ++++-
3 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py
--- a/Lib/sqlite3/test/regression.py
+++ b/Lib/sqlite3/test/regression.py
@@ -330,6 +330,11 @@
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
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -29,6 +29,9 @@
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
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -109,7 +109,10 @@
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);
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list