mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
gh-111089: Use PyUnicode_AsUTF8() in Argument Clinic (#111585)
Replace PyUnicode_AsUTF8AndSize() with PyUnicode_AsUTF8() to remove the explicit check for embedded null characters. The change avoids to have to include explicitly <string.h> to get the strlen() function when using a recent version of the limited C API.
This commit is contained in:
parent
97b3cd38d1
commit
d9b606b3d0
34 changed files with 180 additions and 907 deletions
9
Modules/_sqlite/clinic/module.c.h
generated
9
Modules/_sqlite/clinic/module.c.h
generated
|
@ -60,15 +60,10 @@ pysqlite_complete_statement(PyObject *module, PyObject *const *args, Py_ssize_t
|
|||
_PyArg_BadArgument("complete_statement", "argument 'statement'", "str", args[0]);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t statement_length;
|
||||
statement = PyUnicode_AsUTF8AndSize(args[0], &statement_length);
|
||||
statement = PyUnicode_AsUTF8(args[0]);
|
||||
if (statement == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(statement) != (size_t)statement_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
return_value = pysqlite_complete_statement_impl(module, statement);
|
||||
|
||||
exit:
|
||||
|
@ -208,4 +203,4 @@ skip_optional:
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=457ab0fdbb9e1880 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=19016e67830c19eb input=a9049054013a1b77]*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue