summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-10-20 18:04:27 (GMT)
committerGitHub <noreply@github.com>2023-10-20 18:04:27 (GMT)
commit37e4e20eaa8f27ada926d49e5971fecf0477ad26 (patch)
tree10c1472611083eee037ff84f88617ae0ba9b8fe4
parentea7c26e4b89c71234c4a603567a93f0a44c9cc97 (diff)
downloadcpython-37e4e20eaa8f27ada926d49e5971fecf0477ad26.zip
cpython-37e4e20eaa8f27ada926d49e5971fecf0477ad26.tar.gz
cpython-37e4e20eaa8f27ada926d49e5971fecf0477ad26.tar.bz2
gh-111089: Use PyUnicode_AsUTF8() in sqlite3 (#111122)
PyUnicode_AsUTF8() now raises an exception if the string contains embedded null characters.
-rw-r--r--Modules/_sqlite/connection.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 319ed0c..ce46c1e 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) {