mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +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/Python-tokenize.c.h
generated
9
Python/clinic/Python-tokenize.c.h
generated
|
@ -65,19 +65,14 @@ tokenizeriter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
|||
_PyArg_BadArgument("tokenizeriter", "argument 'encoding'", "str", fastargs[2]);
|
||||
goto exit;
|
||||
}
|
||||
Py_ssize_t encoding_length;
|
||||
encoding = PyUnicode_AsUTF8AndSize(fastargs[2], &encoding_length);
|
||||
encoding = PyUnicode_AsUTF8(fastargs[2]);
|
||||
if (encoding == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
if (strlen(encoding) != (size_t)encoding_length) {
|
||||
PyErr_SetString(PyExc_ValueError, "embedded null character");
|
||||
goto exit;
|
||||
}
|
||||
skip_optional_kwonly:
|
||||
return_value = tokenizeriter_new_impl(type, readline, extra_tokens, encoding);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=dcd6ec48f06a092e input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=92cb8176149f0924 input=a9049054013a1b77]*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue