mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +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
Python/clinic/bltinmodule.c.h
generated
9
Python/clinic/bltinmodule.c.h
generated
|
@ -329,15 +329,10 @@ builtin_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj
|
|||
_PyArg_BadArgument("compile", "argument 'mode'", "str", args[2]);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t mode_length;
|
||||
mode = PyUnicode_AsUTF8AndSize(args[2], &mode_length);
|
||||
mode = PyUnicode_AsUTF8(args[2]);
|
||||
if (mode == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(mode) != (size_t)mode_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
if (!noptargs) {
|
||||
goto skip_optional_pos;
|
||||
}
|
||||
|
@ -1212,4 +1207,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=31bded5d08647a57 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=95d3813b1798f018 input=a9049054013a1b77]*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue