diff options
author | Victor Stinner <vstinner@python.org> | 2020-05-10 09:05:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-10 09:05:29 (GMT) |
commit | 1c2fa781560608aa4be50c748d4b3f403cfa5035 (patch) | |
tree | d9346d8ab7e510f8d296ae37c3401607a2bff4fd /Modules/clinic/posixmodule.c.h | |
parent | fcb285609a2e55f2dc63dcfbb32e4e2fddf71546 (diff) | |
download | cpython-1c2fa781560608aa4be50c748d4b3f403cfa5035.zip cpython-1c2fa781560608aa4be50c748d4b3f403cfa5035.tar.gz cpython-1c2fa781560608aa4be50c748d4b3f403cfa5035.tar.bz2 |
bpo-40549: Convert posixmodule.c to multiphase init (GH-19982)
Convert posixmodule.c ("posix" or "nt" module) to the multiphase
initialization (PEP 489).
* Create the module using PyModuleDef_Init().
* Create ScandirIteratorType and DirEntryType with the new
PyType_FromModuleAndSpec() (PEP 573)
* Get the module state from ScandirIteratorType and DirEntryType with
the new PyType_GetModule() (PEP 573)
* Pass module to functions which access the module state.
* convert_sched_param() gets a new module parameter. It is now called
directly since Argument Clinic doesn't support passing the module
to an argument converter callback.
* Remove _posixstate_global macro.
Diffstat (limited to 'Modules/clinic/posixmodule.c.h')
-rw-r--r-- | Modules/clinic/posixmodule.c.h | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h index a2b4566..cf6d744 100644 --- a/Modules/clinic/posixmodule.c.h +++ b/Modules/clinic/posixmodule.c.h @@ -2886,7 +2886,7 @@ PyDoc_STRVAR(os_sched_setscheduler__doc__, static PyObject * os_sched_setscheduler_impl(PyObject *module, pid_t pid, int policy, - struct sched_param *param); + PyObject *param_obj); static PyObject * os_sched_setscheduler(PyObject *module, PyObject *const *args, Py_ssize_t nargs) @@ -2894,13 +2894,13 @@ os_sched_setscheduler(PyObject *module, PyObject *const *args, Py_ssize_t nargs) PyObject *return_value = NULL; pid_t pid; int policy; - struct sched_param param; + PyObject *param_obj; - if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_PID "iO&:sched_setscheduler", - &pid, &policy, convert_sched_param, ¶m)) { + if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_PID "iO:sched_setscheduler", + &pid, &policy, ¶m_obj)) { goto exit; } - return_value = os_sched_setscheduler_impl(module, pid, policy, ¶m); + return_value = os_sched_setscheduler_impl(module, pid, policy, param_obj); exit: return return_value; @@ -2957,21 +2957,20 @@ PyDoc_STRVAR(os_sched_setparam__doc__, {"sched_setparam", (PyCFunction)(void(*)(void))os_sched_setparam, METH_FASTCALL, os_sched_setparam__doc__}, static PyObject * -os_sched_setparam_impl(PyObject *module, pid_t pid, - struct sched_param *param); +os_sched_setparam_impl(PyObject *module, pid_t pid, PyObject *param_obj); static PyObject * os_sched_setparam(PyObject *module, PyObject *const *args, Py_ssize_t nargs) { PyObject *return_value = NULL; pid_t pid; - struct sched_param param; + PyObject *param_obj; - if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_PID "O&:sched_setparam", - &pid, convert_sched_param, ¶m)) { + if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_PID "O:sched_setparam", + &pid, ¶m_obj)) { goto exit; } - return_value = os_sched_setparam_impl(module, pid, ¶m); + return_value = os_sched_setparam_impl(module, pid, param_obj); exit: return return_value; @@ -9418,4 +9417,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=ba73b68f1c435ff6 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=be90d3aba972098b input=a9049054013a1b77]*/ |