diff options
author | Victor Stinner <vstinner@python.org> | 2023-11-01 15:34:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-01 15:34:42 (GMT) |
commit | d9b606b3d04fc56fb0bcc479d7d6c14562edb5e2 (patch) | |
tree | 14d10605507380e411d5f62e5bab28f74091129d /Python/clinic/sysmodule.c.h | |
parent | 97b3cd38d105fd891ba46dd27d08f03d1c6dd348 (diff) | |
download | cpython-d9b606b3d04fc56fb0bcc479d7d6c14562edb5e2.zip cpython-d9b606b3d04fc56fb0bcc479d7d6c14562edb5e2.tar.gz cpython-d9b606b3d04fc56fb0bcc479d7d6c14562edb5e2.tar.bz2 |
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.
Diffstat (limited to 'Python/clinic/sysmodule.c.h')
-rw-r--r-- | Python/clinic/sysmodule.c.h | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/Python/clinic/sysmodule.c.h b/Python/clinic/sysmodule.c.h index 98717ec..571a34b 100644 --- a/Python/clinic/sysmodule.c.h +++ b/Python/clinic/sysmodule.c.h @@ -1259,15 +1259,10 @@ sys_activate_stack_trampoline(PyObject *module, PyObject *arg) _PyArg_BadArgument("activate_stack_trampoline", "argument", "str", arg); goto exit; } - Py_ssize_t backend_length; - backend = PyUnicode_AsUTF8AndSize(arg, &backend_length); + backend = PyUnicode_AsUTF8(arg); if (backend == NULL) { goto exit; } - if (strlen(backend) != (size_t)backend_length) { - PyErr_SetString(PyExc_ValueError, "embedded null character"); - goto exit; - } return_value = sys_activate_stack_trampoline_impl(module, backend); exit: @@ -1452,4 +1447,4 @@ exit: #ifndef SYS_GETANDROIDAPILEVEL_METHODDEF #define SYS_GETANDROIDAPILEVEL_METHODDEF #endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */ -/*[clinic end generated code: output=f36d45c829250775 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=cdfb714878deeaf1 input=a9049054013a1b77]*/ |