diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-11-10 21:31:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-10 21:31:36 +0200 |
commit | 771bd3c94a366547e0c3451a72a430e1132c1ac1 (patch) | |
tree | 92d9e843024137d115ff9e1fc22399f4707700ef /Modules/_sqlite | |
parent | 3932b0f7b1566374427daa8bc47203032015e350 (diff) | |
download | cpython-771bd3c94a366547e0c3451a72a430e1132c1ac1.tar.gz cpython-771bd3c94a366547e0c3451a72a430e1132c1ac1.zip |
Add private _PyUnicode_AsUTF8NoNUL() function (GH-111957)
Like PyUnicode_AsUTF8(), but check for embedded null characters.
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r-- | Modules/_sqlite/connection.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 319ed0c29c7..0a6633972cc 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -76,16 +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_AsUTF8NoNUL(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) { return 0; |