]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-111089: Use PyUnicode_AsUTF8() in sqlite3 (#111122)
authorVictor Stinner <vstinner@python.org>
Fri, 20 Oct 2023 18:04:27 +0000 (20:04 +0200)
committerGitHub <noreply@github.com>
Fri, 20 Oct 2023 18:04:27 +0000 (20:04 +0200)
PyUnicode_AsUTF8() now raises an exception if the string contains
embedded null characters.

Modules/_sqlite/connection.c

index 319ed0c29c7a9b617c7d91ee4efc988b635df13e..ce46c1e69f31310fd019e8c9ed6a0e72b1c39ed5 100644 (file)
@@ -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) {