summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-11-15 12:55:38 (GMT)
committerGitHub <noreply@github.com>2021-11-15 12:55:38 (GMT)
commit822c3dcce3996e411c1ff5c432c6ac7d2845cfd6 (patch)
treede99f1c8a4bd45d891568a449846053fa9e3b7de /Modules/_sqlite
parentb567b9d74bd9e476a3027335873bb0508d6e450f (diff)
downloadcpython-822c3dcce3996e411c1ff5c432c6ac7d2845cfd6.zip
cpython-822c3dcce3996e411c1ff5c432c6ac7d2845cfd6.tar.gz
cpython-822c3dcce3996e411c1ff5c432c6ac7d2845cfd6.tar.bz2
bpo-45512: Raise exception if sqlite3.Connection.__init__ is called with bad isolation level (#29561)
* bpo-45512: Raise sqlite3.Connection.__init__ is called with bad isolation level * Also explicitly test allowed isolation levels * Use subTest for better error messages if something goes wrong * Update Lib/test/test_sqlite3/test_dbapi.py Co-authored-by: Dong-hee Na <donghee.na92@gmail.com> Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r--Modules/_sqlite/connection.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index e4f0013..b902dc8 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -127,6 +127,9 @@ get_begin_statement(const char *level)
return begin_statements[i];
}
}
+ PyErr_SetString(PyExc_ValueError,
+ "isolation_level string must be '', 'DEFERRED', "
+ "'IMMEDIATE', or 'EXCLUSIVE'");
return NULL;
}
@@ -1389,9 +1392,6 @@ pysqlite_connection_set_isolation_level(pysqlite_Connection* self, PyObject* iso
}
const char *stmt = get_begin_statement(cstr_level);
if (stmt == NULL) {
- PyErr_SetString(PyExc_ValueError,
- "isolation_level string must be '', 'DEFERRED', "
- "'IMMEDIATE', or 'EXCLUSIVE'");
return -1;
}
self->begin_statement = stmt;