Skip to content

Commit 37e4e20

Browse files
authored
gh-111089: Use PyUnicode_AsUTF8() in sqlite3 (#111122)
PyUnicode_AsUTF8() now raises an exception if the string contains embedded null characters.
1 parent ea7c26e commit 37e4e20

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

Modules/_sqlite/connection.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,10 @@ isolation_level_converter(PyObject *str_or_none, const char **result)
7676
*result = NULL;
7777
}
7878
else if (PyUnicode_Check(str_or_none)) {
79-
Py_ssize_t sz;
80-
const char *str = PyUnicode_AsUTF8AndSize(str_or_none, &sz);
79+
const char *str = PyUnicode_AsUTF8(str_or_none);
8180
if (str == NULL) {
8281
return 0;
8382
}
84-
if (strlen(str) != (size_t)sz) {
85-
PyErr_SetString(PyExc_ValueError, "embedded null character");
86-
return 0;
87-
}
8883

8984
const char *level = get_isolation_level(str);
9085
if (level == NULL) {

0 commit comments

Comments
 (0)