mirror of https://github.com/python/cpython
gh-111089: Use PyUnicode_AsUTF8() in sqlite3 (#111122)
PyUnicode_AsUTF8() now raises an exception if the string contains embedded null characters.
This commit is contained in:
parent
ea7c26e4b8
commit
37e4e20eaa
|
@ -76,15 +76,10 @@ isolation_level_converter(PyObject *str_or_none, const char **result)
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
}
|
}
|
||||||
else if (PyUnicode_Check(str_or_none)) {
|
else if (PyUnicode_Check(str_or_none)) {
|
||||||
Py_ssize_t sz;
|
const char *str = PyUnicode_AsUTF8(str_or_none);
|
||||||
const char *str = PyUnicode_AsUTF8AndSize(str_or_none, &sz);
|
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (strlen(str) != (size_t)sz) {
|
|
||||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *level = get_isolation_level(str);
|
const char *level = get_isolation_level(str);
|
||||||
if (level == NULL) {
|
if (level == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue