Skip to content

Commit

Permalink
pythongh-111089: Use PyUnicode_AsUTF8() in sqlite3 (python#111122)
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 authored Oct 20, 2023
1 parent ea7c26e commit 37e4e20
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 37e4e20

Please sign in to comment.