Skip to content

Commit

Permalink
pythongh-111089: Use PyUnicode_AsUTF8() in sqlite3
Browse files Browse the repository at this point in the history
PyUnicode_AsUTF8() now raises an exception if the string contains
embedded null characters.
  • Loading branch information
vstinner committed Oct 20, 2023
1 parent d731579 commit 714c652
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,10 @@ isolation_level_converter(PyObject *str_or_none, const char **result)
*result = NULL;
}
else if (PyUnicode_Check(str_or_none)) {
Py_ssize_t sz;
const char *str = PyUnicode_AsUTF8AndSize(str_or_none, &sz);
const char *str = PyUnicode_AsUTF8(str_or_none);
if (str == NULL) {
return 0;
}
if (strlen(str) != (size_t)sz) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
return 0;
}

const char *level = get_isolation_level(str);
if (level == NULL) {
Expand Down

0 comments on commit 714c652

Please sign in to comment.