Skip to content

Commit

Permalink
Revert "pythongh-111089: Use PyUnicode_AsUTF8() in sqlite3 (python#11…
Browse files Browse the repository at this point in the history
…1122)"

This reverts commit 37e4e20.
  • Loading branch information
vstinner committed Nov 7, 2023
1 parent 0e87483 commit 8b4a011
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,15 @@ isolation_level_converter(PyObject *str_or_none, const char **result)
*result = NULL;
}
else if (PyUnicode_Check(str_or_none)) {
const char *str = PyUnicode_AsUTF8(str_or_none);
Py_ssize_t sz;
const char *str = PyUnicode_AsUTF8AndSize(str_or_none, &sz);
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 8b4a011

Please sign in to comment.