summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorOleg Iarygin <oleg@arhadthedev.net>2022-07-04 13:11:11 (GMT)
committerGitHub <noreply@github.com>2022-07-04 13:11:11 (GMT)
commit670f7f10cf9cd7bdde9e62660d85506823f5bf7c (patch)
tree40ab8707bc072640973d93cce548bcff93931f7e /Modules
parent9b50f76fcdb48cae10fe954ab6f659a4ceff4c0c (diff)
downloadcpython-670f7f10cf9cd7bdde9e62660d85506823f5bf7c.zip
cpython-670f7f10cf9cd7bdde9e62660d85506823f5bf7c.tar.gz
cpython-670f7f10cf9cd7bdde9e62660d85506823f5bf7c.tar.bz2
gh-94512: Fix forced arg format in AC-processed multiprocessing (GH-94517)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_multiprocessing/clinic/multiprocessing.c.h30
-rw-r--r--Modules/_multiprocessing/multiprocessing.c10
2 files changed, 33 insertions, 7 deletions
diff --git a/Modules/_multiprocessing/clinic/multiprocessing.c.h b/Modules/_multiprocessing/clinic/multiprocessing.c.h
index e995321..3a30833 100644
--- a/Modules/_multiprocessing/clinic/multiprocessing.c.h
+++ b/Modules/_multiprocessing/clinic/multiprocessing.c.h
@@ -21,7 +21,8 @@ _multiprocessing_closesocket(PyObject *module, PyObject *arg)
PyObject *return_value = NULL;
HANDLE handle;
- if (!PyArg_Parse(arg, ""F_HANDLE":closesocket", &handle)) {
+ handle = PyLong_AsVoidPtr(arg);
+ if (!handle && PyErr_Occurred()) {
goto exit;
}
return_value = _multiprocessing_closesocket_impl(module, handle);
@@ -52,8 +53,15 @@ _multiprocessing_recv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
HANDLE handle;
int size;
- if (!_PyArg_ParseStack(args, nargs, ""F_HANDLE"i:recv",
- &handle, &size)) {
+ if (!_PyArg_CheckPositional("recv", nargs, 2, 2)) {
+ goto exit;
+ }
+ handle = PyLong_AsVoidPtr(args[0]);
+ if (!handle && PyErr_Occurred()) {
+ goto exit;
+ }
+ size = _PyLong_AsInt(args[1]);
+ if (size == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _multiprocessing_recv_impl(module, handle, size);
@@ -84,8 +92,18 @@ _multiprocessing_send(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
HANDLE handle;
Py_buffer buf = {NULL, NULL};
- if (!_PyArg_ParseStack(args, nargs, ""F_HANDLE"y*:send",
- &handle, &buf)) {
+ if (!_PyArg_CheckPositional("send", nargs, 2, 2)) {
+ goto exit;
+ }
+ handle = PyLong_AsVoidPtr(args[0]);
+ if (!handle && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (PyObject_GetBuffer(args[1], &buf, PyBUF_SIMPLE) != 0) {
+ goto exit;
+ }
+ if (!PyBuffer_IsContiguous(&buf, 'C')) {
+ _PyArg_BadArgument("send", "argument 2", "contiguous buffer", args[1]);
goto exit;
}
return_value = _multiprocessing_send_impl(module, handle, &buf);
@@ -148,4 +166,4 @@ exit:
#ifndef _MULTIPROCESSING_SEND_METHODDEF
#define _MULTIPROCESSING_SEND_METHODDEF
#endif /* !defined(_MULTIPROCESSING_SEND_METHODDEF) */
-/*[clinic end generated code: output=d3bbf69de578db7b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ab64ce752f933c55 input=a9049054013a1b77]*/
diff --git a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c
index 0809c24..ed89a1e 100644
--- a/Modules/_multiprocessing/multiprocessing.c
+++ b/Modules/_multiprocessing/multiprocessing.c
@@ -14,8 +14,16 @@ class HANDLE_converter(CConverter):
type = "HANDLE"
format_unit = '"F_HANDLE"'
+ def parse_arg(self, argname, displayname):
+ return """
+ {paramname} = PyLong_AsVoidPtr({argname});
+ if (!{paramname} && PyErr_Occurred()) {{{{
+ goto exit;
+ }}}}
+ """.format(argname=argname, paramname=self.parser_name)
+
[python start generated code]*/
-/*[python end generated code: output=da39a3ee5e6b4b0d input=9fad6080b79ace91]*/
+/*[python end generated code: output=da39a3ee5e6b4b0d input=3e537d244034affb]*/
/*[clinic input]
module _multiprocessing