mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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>
This commit is contained in:
parent
b567b9d74b
commit
822c3dcce3
2 changed files with 19 additions and 5 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue