summaryrefslogtreecommitdiffstats
path: root/Modules/clinic/posixmodule.c.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-11-01 15:34:42 (GMT)
committerGitHub <noreply@github.com>2023-11-01 15:34:42 (GMT)
commitd9b606b3d04fc56fb0bcc479d7d6c14562edb5e2 (patch)
tree14d10605507380e411d5f62e5bab28f74091129d /Modules/clinic/posixmodule.c.h
parent97b3cd38d105fd891ba46dd27d08f03d1c6dd348 (diff)
downloadcpython-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 'Modules/clinic/posixmodule.c.h')
-rw-r--r--Modules/clinic/posixmodule.c.h16
1 files changed, 3 insertions, 13 deletions
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h
index 9473dd7..d91793c 100644
--- a/Modules/clinic/posixmodule.c.h
+++ b/Modules/clinic/posixmodule.c.h
@@ -4672,15 +4672,10 @@ os_getgrouplist(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
_PyArg_BadArgument("getgrouplist", "argument 1", "str", args[0]);
goto exit;
}
- Py_ssize_t user_length;
- user = PyUnicode_AsUTF8AndSize(args[0], &user_length);
+ user = PyUnicode_AsUTF8(args[0]);
if (user == NULL) {
goto exit;
}
- if (strlen(user) != (size_t)user_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
basegid = PyLong_AsInt(args[1]);
if (basegid == -1 && PyErr_Occurred()) {
goto exit;
@@ -4726,15 +4721,10 @@ os_getgrouplist(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
_PyArg_BadArgument("getgrouplist", "argument 1", "str", args[0]);
goto exit;
}
- Py_ssize_t user_length;
- user = PyUnicode_AsUTF8AndSize(args[0], &user_length);
+ user = PyUnicode_AsUTF8(args[0]);
if (user == NULL) {
goto exit;
}
- if (strlen(user) != (size_t)user_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
if (!_Py_Gid_Converter(args[1], &basegid)) {
goto exit;
}
@@ -12403,4 +12393,4 @@ exit:
#ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF
#define OS_WAITSTATUS_TO_EXITCODE_METHODDEF
#endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */
-/*[clinic end generated code: output=a05abdc48e3def44 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a377982a6d1e77b9 input=a9049054013a1b77]*/