FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Issue #20026: Fix the sqlite module to handle correctly invalid isola… · python-emscripten/cpython@cb1f74e · GitHub

Repository navigation

Commit cb1f74e

Browse files
committed
Issue python#20026: Fix the sqlite module to handle correctly invalid isolation level
(wrong type).
1 parent cac23a5 commit cb1f74e

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎Lib/sqlite3/test/regression.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,11 @@ def CheckConvertTimestampMicrosecondPadding(self):
330330
datetime.datetime(2012, 4, 4, 15, 6, 0, 123456),
331331
])
332332

333+
def CheckInvalidIsolationLevelType(self):
334+
# isolation level is a string, not an integer
335+
self.assertRaises(TypeError,
336+
sqlite.connect, ":memory:", isolation_level=123)
337+
333338

334339
def suite():
335340
regression_suite = unittest.makeSuite(RegressionTests, "Check")

‎Misc/NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ Core and Builtins
2929
Library
3030
-------
3131

32+
- Issue #20026: Fix the sqlite module to handle correctly invalid isolation
33+
level (wrong type).
34+
3235
- Issue #18829: csv.Dialect() now checks type for delimiter, escapechar and
3336
quotechar fields. Original patch by Vajrasky Kok.
3437

‎Modules/_sqlite/connection.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
109109
Py_INCREF(isolation_level);
110110
}
111111
self->isolation_level = NULL;
112-
pysqlite_connection_set_isolation_level(self, isolation_level);
112+
if (pysqlite_connection_set_isolation_level(self, isolation_level) < 0) {
113+
Py_DECREF(isolation_level);
114+
return -1;
115+
}
113116
Py_DECREF(isolation_level);
114117

115118
self->statement_cache = (pysqlite_Cache*)PyObject_CallFunction((PyObject*)&pysqlite_CacheType, "Oi", self, cached_statements);

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL