Skip to content

bpo-20175: Convert Modules/_multiprocessing to the Argument Clinic #14245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Make the requested changes.
  • Loading branch information
ZackerySpytz committed Jul 12, 2020
commit 87cfe163b435e8e8045d47aa1a0f34d8ec2b8068
4 changes: 2 additions & 2 deletions Modules/_multiprocessing/clinic/multiprocessing.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ _multiprocessing_sem_unlink(PyObject *module, PyObject *arg)
const char *name;

if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("sem_unlink", 0, "str", arg);
_PyArg_BadArgument("sem_unlink", "argument", "str", arg);
goto exit;
}
Py_ssize_t name_length;
Expand Down Expand Up @@ -148,4 +148,4 @@ _multiprocessing_sem_unlink(PyObject *module, PyObject *arg)
#ifndef _MULTIPROCESSING_SEND_METHODDEF
#define _MULTIPROCESSING_SEND_METHODDEF
#endif /* !defined(_MULTIPROCESSING_SEND_METHODDEF) */
/*[clinic end generated code: output=0e7388750e2d4920 input=a9049054013a1b77]*/
/*[clinic end generated code: output=418191c446cd5751 input=a9049054013a1b77]*/
60 changes: 15 additions & 45 deletions Modules/_multiprocessing/clinic/semaphore.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ preserve
#if defined(MS_WINDOWS)

PyDoc_STRVAR(_multiprocessing_SemLock_acquire__doc__,
"acquire($self, /, block=1, timeout=None)\n"
"acquire($self, /, block=True, timeout=None)\n"
"--\n"
"\n"
"acquire the semaphore/lock");
"Acquire the semaphore/lock.");

#define _MULTIPROCESSING_SEMLOCK_ACQUIRE_METHODDEF \
{"acquire", (PyCFunction)(void(*)(void))_multiprocessing_SemLock_acquire, METH_FASTCALL|METH_KEYWORDS, _multiprocessing_SemLock_acquire__doc__},
Expand Down Expand Up @@ -36,11 +36,6 @@ _multiprocessing_SemLock_acquire(SemLockObject *self, PyObject *const *args, Py_
goto skip_optional_pos;
}
if (args[0]) {
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
blocking = _PyLong_AsInt(args[0]);
if (blocking == -1 && PyErr_Occurred()) {
goto exit;
Expand All @@ -65,7 +60,7 @@ PyDoc_STRVAR(_multiprocessing_SemLock_release__doc__,
"release($self, /)\n"
"--\n"
"\n"
"release the semaphore/lock");
"Release the semaphore/lock.");

#define _MULTIPROCESSING_SEMLOCK_RELEASE_METHODDEF \
{"release", (PyCFunction)_multiprocessing_SemLock_release, METH_NOARGS, _multiprocessing_SemLock_release__doc__},
Expand All @@ -84,10 +79,10 @@ _multiprocessing_SemLock_release(SemLockObject *self, PyObject *Py_UNUSED(ignore
#if !defined(MS_WINDOWS)

PyDoc_STRVAR(_multiprocessing_SemLock_acquire__doc__,
"acquire($self, /, block=1, timeout=None)\n"
"acquire($self, /, block=True, timeout=None)\n"
"--\n"
"\n"
"acquire the semaphore/lock");
"Acquire the semaphore/lock.");

#define _MULTIPROCESSING_SEMLOCK_ACQUIRE_METHODDEF \
{"acquire", (PyCFunction)(void(*)(void))_multiprocessing_SemLock_acquire, METH_FASTCALL|METH_KEYWORDS, _multiprocessing_SemLock_acquire__doc__},
Expand Down Expand Up @@ -115,11 +110,6 @@ _multiprocessing_SemLock_acquire(SemLockObject *self, PyObject *const *args, Py_
goto skip_optional_pos;
}
if (args[0]) {
if (PyFloat_Check(args[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
blocking = _PyLong_AsInt(args[0]);
if (blocking == -1 && PyErr_Occurred()) {
goto exit;
Expand All @@ -144,7 +134,7 @@ PyDoc_STRVAR(_multiprocessing_SemLock_release__doc__,
"release($self, /)\n"
"--\n"
"\n"
"release the semaphore/lock");
"Release the semaphore/lock.");

#define _MULTIPROCESSING_SEMLOCK_RELEASE_METHODDEF \
{"release", (PyCFunction)_multiprocessing_SemLock_release, METH_NOARGS, _multiprocessing_SemLock_release__doc__},
Expand Down Expand Up @@ -183,35 +173,20 @@ _multiprocessing_SemLock(PyTypeObject *type, PyObject *args, PyObject *kwargs)
if (!fastargs) {
goto exit;
}
if (PyFloat_Check(fastargs[0])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
kind = _PyLong_AsInt(fastargs[0]);
if (kind == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(fastargs[1])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
value = _PyLong_AsInt(fastargs[1]);
if (value == -1 && PyErr_Occurred()) {
goto exit;
}
if (PyFloat_Check(fastargs[2])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
maxvalue = _PyLong_AsInt(fastargs[2]);
if (maxvalue == -1 && PyErr_Occurred()) {
goto exit;
}
if (!PyUnicode_Check(fastargs[3])) {
_PyArg_BadArgument("SemLock", 4, "str", fastargs[3]);
_PyArg_BadArgument("SemLock", "argument 'name'", "str", fastargs[3]);
goto exit;
}
Py_ssize_t name_length;
Expand All @@ -223,11 +198,6 @@ _multiprocessing_SemLock(PyTypeObject *type, PyObject *args, PyObject *kwargs)
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
if (PyFloat_Check(fastargs[4])) {
PyErr_SetString(PyExc_TypeError,
"integer argument expected, got float" );
goto exit;
}
unlink = _PyLong_AsInt(fastargs[4]);
if (unlink == -1 && PyErr_Occurred()) {
goto exit;
Expand Down Expand Up @@ -274,7 +244,7 @@ PyDoc_STRVAR(_multiprocessing_SemLock__count__doc__,
"_count($self, /)\n"
"--\n"
"\n"
"num of `acquire()`s minus num of `release()`s for this process");
"Num of `acquire()`s minus num of `release()`s for this process.");

#define _MULTIPROCESSING_SEMLOCK__COUNT_METHODDEF \
{"_count", (PyCFunction)_multiprocessing_SemLock__count, METH_NOARGS, _multiprocessing_SemLock__count__doc__},
Expand All @@ -292,7 +262,7 @@ PyDoc_STRVAR(_multiprocessing_SemLock__is_mine__doc__,
"_is_mine($self, /)\n"
"--\n"
"\n"
"whether the lock is owned by this thread");
"Whether the lock is owned by this thread.");

#define _MULTIPROCESSING_SEMLOCK__IS_MINE_METHODDEF \
{"_is_mine", (PyCFunction)_multiprocessing_SemLock__is_mine, METH_NOARGS, _multiprocessing_SemLock__is_mine__doc__},
Expand All @@ -310,7 +280,7 @@ PyDoc_STRVAR(_multiprocessing_SemLock__get_value__doc__,
"_get_value($self, /)\n"
"--\n"
"\n"
"get the value of the semaphore");
"Get the value of the semaphore.");

#define _MULTIPROCESSING_SEMLOCK__GET_VALUE_METHODDEF \
{"_get_value", (PyCFunction)_multiprocessing_SemLock__get_value, METH_NOARGS, _multiprocessing_SemLock__get_value__doc__},
Expand All @@ -328,7 +298,7 @@ PyDoc_STRVAR(_multiprocessing_SemLock__is_zero__doc__,
"_is_zero($self, /)\n"
"--\n"
"\n"
"returns whether semaphore has value zero");
"Return whether semaphore has value zero.");

#define _MULTIPROCESSING_SEMLOCK__IS_ZERO_METHODDEF \
{"_is_zero", (PyCFunction)_multiprocessing_SemLock__is_zero, METH_NOARGS, _multiprocessing_SemLock__is_zero__doc__},
Expand All @@ -346,7 +316,7 @@ PyDoc_STRVAR(_multiprocessing_SemLock__after_fork__doc__,
"_after_fork($self, /)\n"
"--\n"
"\n"
"rezero the net acquisition count after fork()");
"Rezero the net acquisition count after fork().");

#define _MULTIPROCESSING_SEMLOCK__AFTER_FORK_METHODDEF \
{"_after_fork", (PyCFunction)_multiprocessing_SemLock__after_fork, METH_NOARGS, _multiprocessing_SemLock__after_fork__doc__},
Expand All @@ -364,7 +334,7 @@ PyDoc_STRVAR(_multiprocessing_SemLock___enter____doc__,
"__enter__($self, /)\n"
"--\n"
"\n"
"enter the semaphore/lock");
"Enter the semaphore/lock.");

#define _MULTIPROCESSING_SEMLOCK___ENTER___METHODDEF \
{"__enter__", (PyCFunction)_multiprocessing_SemLock___enter__, METH_NOARGS, _multiprocessing_SemLock___enter____doc__},
Expand All @@ -382,7 +352,7 @@ PyDoc_STRVAR(_multiprocessing_SemLock___exit____doc__,
"__exit__($self, exc_type=None, exc_value=None, exc_tb=None, /)\n"
"--\n"
"\n"
"exit the semaphore/lock");
"Exit the semaphore/lock.");

#define _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF \
{"__exit__", (PyCFunction)(void(*)(void))_multiprocessing_SemLock___exit__, METH_FASTCALL, _multiprocessing_SemLock___exit____doc__},
Expand Down Expand Up @@ -429,4 +399,4 @@ _multiprocessing_SemLock___exit__(SemLockObject *self, PyObject *const *args, Py
#ifndef _MULTIPROCESSING_SEMLOCK_RELEASE_METHODDEF
#define _MULTIPROCESSING_SEMLOCK_RELEASE_METHODDEF
#endif /* !defined(_MULTIPROCESSING_SEMLOCK_RELEASE_METHODDEF) */
/*[clinic end generated code: output=23e54ef808b77beb input=a9049054013a1b77]*/
/*[clinic end generated code: output=e7fd938150601fe5 input=a9049054013a1b77]*/
1 change: 0 additions & 1 deletion Modules/_multiprocessing/multiprocessing.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ _multiprocessing_send_impl(PyObject *module, HANDLE handle, Py_buffer *buf)
ret = send((SOCKET) handle, buf->buf, length, 0);
Py_END_ALLOW_THREADS

PyBuffer_Release(buf);
if (ret < 0)
return PyErr_SetExcFromWindowsErr(PyExc_OSError, WSAGetLastError());
return PyLong_FromLong(ret);
Expand Down
Loading