From: Victor Stinner Date: Fri, 20 Oct 2023 18:04:27 +0000 (+0200) Subject: gh-111089: Use PyUnicode_AsUTF8() in sqlite3 (#111122) X-Git-Tag: v3.13.0a2~383 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=37e4e20eaa8f27ada926d49e5971fecf0477ad26;p=thirdparty%2FPython%2Fcpython.git gh-111089: Use PyUnicode_AsUTF8() in sqlite3 (#111122) PyUnicode_AsUTF8() now raises an exception if the string contains embedded null characters. --- diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 319ed0c29c7a..ce46c1e69f31 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -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) {