Skip to content

Commit cde1071

Browse files
authored
gh-111089: Use PyUnicode_AsUTF8() in getargs.c (#111620)
Replace PyUnicode_AsUTF8AndSize() with PyUnicode_AsUTF8() to remove the explicit check for embedded null characters.
1 parent ff3b0a6 commit cde1071

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

Python/getargs.c

+2-6
Original file line numberDiff line numberDiff line change
@@ -932,19 +932,15 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
932932
} else {
933933
/* "s" or "z" */
934934
const char **p = va_arg(*p_va, const char **);
935-
Py_ssize_t len;
936935
sarg = NULL;
937936

938937
if (c == 'z' && arg == Py_None)
939938
*p = NULL;
940939
else if (PyUnicode_Check(arg)) {
941-
sarg = PyUnicode_AsUTF8AndSize(arg, &len);
942-
if (sarg == NULL)
940+
sarg = PyUnicode_AsUTF8(arg);
941+
if (sarg == NULL) {
943942
return converterr(CONV_UNICODE,
944943
arg, msgbuf, bufsize);
945-
if (strlen(sarg) != (size_t)len) {
946-
PyErr_SetString(PyExc_ValueError, "embedded null character");
947-
RETURN_ERR_OCCURRED;
948944
}
949945
*p = sarg;
950946
}

0 commit comments

Comments
 (0)