summaryrefslogtreecommitdiffstats
path: root/Python/getargs.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-11-01 23:13:55 (GMT)
committerGitHub <noreply@github.com>2023-11-01 23:13:55 (GMT)
commitcde1071b2a72e8261ca66053ef61431b7f3a81fd (patch)
tree4eb45c22d82de42c01efc6d99702c234fbf51ed3 /Python/getargs.c
parentff3b0a69380f8487ff0b7a78733b1421df1c4663 (diff)
downloadcpython-cde1071b2a72e8261ca66053ef61431b7f3a81fd.zip
cpython-cde1071b2a72e8261ca66053ef61431b7f3a81fd.tar.gz
cpython-cde1071b2a72e8261ca66053ef61431b7f3a81fd.tar.bz2
gh-111089: Use PyUnicode_AsUTF8() in getargs.c (#111620)
Replace PyUnicode_AsUTF8AndSize() with PyUnicode_AsUTF8() to remove the explicit check for embedded null characters.
Diffstat (limited to 'Python/getargs.c')
-rw-r--r--Python/getargs.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index 5a12ca8..4d91818 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -932,19 +932,15 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
} else {
/* "s" or "z" */
const char **p = va_arg(*p_va, const char **);
- Py_ssize_t len;
sarg = NULL;
if (c == 'z' && arg == Py_None)
*p = NULL;
else if (PyUnicode_Check(arg)) {
- sarg = PyUnicode_AsUTF8AndSize(arg, &len);
- if (sarg == NULL)
+ sarg = PyUnicode_AsUTF8(arg);
+ if (sarg == NULL) {
return converterr(CONV_UNICODE,
arg, msgbuf, bufsize);
- if (strlen(sarg) != (size_t)len) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- RETURN_ERR_OCCURRED;
}
*p = sarg;
}