From 4ac7307a1dd32a3419ad893936d3914de7f4f92b Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 16:55:48 +0100 Subject: [PATCH 01/16] Convert _interpqueues.create() --- Modules/_interpqueuesmodule.c | 49 ++++++------ Modules/clinic/_interpqueuesmodule.c.h | 105 +++++++++++++++++++++++++ 2 files changed, 131 insertions(+), 23 deletions(-) create mode 100644 Modules/clinic/_interpqueuesmodule.c.h diff --git a/Modules/_interpqueuesmodule.c b/Modules/_interpqueuesmodule.c index e5afe746f90bdc..153b188a29239a 100644 --- a/Modules/_interpqueuesmodule.c +++ b/Modules/_interpqueuesmodule.c @@ -16,12 +16,19 @@ #undef HAS_FALLBACK #undef REGISTERS_HEAP_TYPES +#include "clinic/_interpqueuesmodule.c.h" + #define MODULE_NAME _interpqueues #define MODULE_NAME_STR Py_STRINGIFY(MODULE_NAME) #define MODINIT_FUNC_NAME RESOLVE_MODINIT_FUNC_NAME(MODULE_NAME) +/*[clinic input] +module _interpqueues +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=cb1313f77fab132b]*/ + #define GLOBAL_MALLOC(TYPE) \ PyMem_RawMalloc(sizeof(TYPE)) #define GLOBAL_FREE(VAR) \ @@ -1479,18 +1486,24 @@ qidarg_converter(PyObject *arg, void *ptr) } +/*[clinic input] +_interpqueues.create + maxsize: Py_ssize_t + unboundop as unboundarg: int = -1 + fallback as fallbackarg: int = -1 + +Create a new cross-interpreter queue and return its unique generated ID. + +It is a new reference as though bind() had been called on the queue. +The caller is responsible for calling destroy() for the new queue +before the runtime is finalized. +[clinic start generated code]*/ + static PyObject * -queuesmod_create(PyObject *self, PyObject *args, PyObject *kwds) +_interpqueues_create_impl(PyObject *module, Py_ssize_t maxsize, + int unboundarg, int fallbackarg) +/*[clinic end generated code: output=9a889b93773251eb input=4f79b710a87360e1]*/ { - static char *kwlist[] = {"maxsize", "unboundop", "fallback", NULL}; - Py_ssize_t maxsize; - int unboundarg = -1; - int fallbackarg = -1; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "n|ii:create", kwlist, - &maxsize, &unboundarg, &fallbackarg)) - { - return NULL; - } struct _queuedefaults defaults = {0}; if (resolve_unboundop(unboundarg, UNBOUND_REPLACE, &defaults.unboundop) < 0) @@ -1505,7 +1518,7 @@ queuesmod_create(PyObject *self, PyObject *args, PyObject *kwds) int64_t qid = queue_create(&_globals.queues, maxsize, defaults); if (qid < 0) { - (void)handle_queue_error((int)qid, self, qid); + (void)handle_queue_error((int)qid, module, qid); return NULL; } @@ -1513,7 +1526,7 @@ queuesmod_create(PyObject *self, PyObject *args, PyObject *kwds) if (qidobj == NULL) { PyObject *exc = PyErr_GetRaisedException(); int err = queue_destroy(&_globals.queues, qid); - if (handle_queue_error(err, self, qid)) { + if (handle_queue_error(err, module, qid)) { // XXX issue a warning? PyErr_Clear(); } @@ -1524,15 +1537,6 @@ queuesmod_create(PyObject *self, PyObject *args, PyObject *kwds) return qidobj; } -PyDoc_STRVAR(queuesmod_create_doc, -"create(maxsize, unboundop, fallback) -> qid\n\ -\n\ -Create a new cross-interpreter queue and return its unique generated ID.\n\ -It is a new reference as though bind() had been called on the queue.\n\ -\n\ -The caller is responsible for calling destroy() for the new queue\n\ -before the runtime is finalized."); - static PyObject * queuesmod_destroy(PyObject *self, PyObject *args, PyObject *kwds) { @@ -1882,8 +1886,7 @@ queuesmod__register_heap_types(PyObject *self, PyObject *args, PyObject *kwds) } static PyMethodDef module_functions[] = { - {"create", _PyCFunction_CAST(queuesmod_create), - METH_VARARGS | METH_KEYWORDS, queuesmod_create_doc}, + _INTERPQUEUES_CREATE_METHODDEF {"destroy", _PyCFunction_CAST(queuesmod_destroy), METH_VARARGS | METH_KEYWORDS, queuesmod_destroy_doc}, {"list_all", queuesmod_list_all, diff --git a/Modules/clinic/_interpqueuesmodule.c.h b/Modules/clinic/_interpqueuesmodule.c.h new file mode 100644 index 00000000000000..21367c65f34cc6 --- /dev/null +++ b/Modules/clinic/_interpqueuesmodule.c.h @@ -0,0 +1,105 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) +# include "pycore_gc.h" // PyGC_Head +# include "pycore_runtime.h" // _Py_ID() +#endif +#include "pycore_abstract.h" // _PyNumber_Index() +#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() + +PyDoc_STRVAR(_interpqueues_create__doc__, +"create($module, /, maxsize, unboundop=-1, fallback=-1)\n" +"--\n" +"\n" +"Create a new cross-interpreter queue and return its unique generated ID.\n" +"\n" +"It is a new reference as though bind() had been called on the queue.\n" +"The caller is responsible for calling destroy() for the new queue\n" +"before the runtime is finalized."); + +#define _INTERPQUEUES_CREATE_METHODDEF \ + {"create", _PyCFunction_CAST(_interpqueues_create), METH_FASTCALL|METH_KEYWORDS, _interpqueues_create__doc__}, + +static PyObject * +_interpqueues_create_impl(PyObject *module, Py_ssize_t maxsize, + int unboundarg, int fallbackarg); + +static PyObject * +_interpqueues_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 3 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(maxsize), &_Py_ID(unboundop), &_Py_ID(fallback), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"maxsize", "unboundop", "fallback", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "create", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[3]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; + Py_ssize_t maxsize; + int unboundarg = -1; + int fallbackarg = -1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + { + Py_ssize_t ival = -1; + PyObject *iobj = _PyNumber_Index(args[0]); + if (iobj != NULL) { + ival = PyLong_AsSsize_t(iobj); + Py_DECREF(iobj); + } + if (ival == -1 && PyErr_Occurred()) { + goto exit; + } + maxsize = ival; + } + if (!noptargs) { + goto skip_optional_pos; + } + if (args[1]) { + unboundarg = PyLong_AsInt(args[1]); + if (unboundarg == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + fallbackarg = PyLong_AsInt(args[2]); + if (fallbackarg == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: + return_value = _interpqueues_create_impl(module, maxsize, unboundarg, fallbackarg); + +exit: + return return_value; +} +/*[clinic end generated code: output=ffb86a2fbab62e69 input=a9049054013a1b77]*/ From b28e3036b05b611e6f39cace992cfeb5dfcddaf9 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 17:44:16 +0100 Subject: [PATCH 02/16] Convert _interpqueues.destroy() --- Modules/_interpqueuesmodule.c | 39 +++++++++------- Modules/clinic/_interpqueuesmodule.c.h | 64 +++++++++++++++++++++++++- 2 files changed, 86 insertions(+), 17 deletions(-) diff --git a/Modules/_interpqueuesmodule.c b/Modules/_interpqueuesmodule.c index 153b188a29239a..20553cedb447ce 100644 --- a/Modules/_interpqueuesmodule.c +++ b/Modules/_interpqueuesmodule.c @@ -29,6 +29,16 @@ module _interpqueues [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=cb1313f77fab132b]*/ +/*[python input] + +class qidarg_converter(CConverter): + type = 'qidarg_converter_data' + converter = 'qidarg_converter' + c_default='{0}' + +[python start generated code]*/ +/*[python end generated code: output=da39a3ee5e6b4b0d input=055fedf5dfa38d4d]*/ + #define GLOBAL_MALLOC(TYPE) \ PyMem_RawMalloc(sizeof(TYPE)) #define GLOBAL_FREE(VAR) \ @@ -1537,30 +1547,28 @@ _interpqueues_create_impl(PyObject *module, Py_ssize_t maxsize, return qidobj; } +/*[clinic input] +_interpqueues.destroy + qid as qidarg: qidarg + +Clear and destroy the queue. + +Afterward attempts to use the queue will behave as though it never existed. +[clinic start generated code]*/ + static PyObject * -queuesmod_destroy(PyObject *self, PyObject *args, PyObject *kwds) +_interpqueues_destroy_impl(PyObject *module, qidarg_converter_data qidarg) +/*[clinic end generated code: output=d362df720aded31a input=d77908b36282e0a2]*/ { - static char *kwlist[] = {"qid", NULL}; - qidarg_converter_data qidarg = {0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&:destroy", kwlist, - qidarg_converter, &qidarg)) { - return NULL; - } int64_t qid = qidarg.id; int err = queue_destroy(&_globals.queues, qid); - if (handle_queue_error(err, self, qid)) { + if (handle_queue_error(err, module, qid)) { return NULL; } Py_RETURN_NONE; } -PyDoc_STRVAR(queuesmod_destroy_doc, -"destroy(qid)\n\ -\n\ -Clear and destroy the queue. Afterward attempts to use the queue\n\ -will behave as though it never existed."); - static PyObject * queuesmod_list_all(PyObject *self, PyObject *Py_UNUSED(ignored)) { @@ -1887,8 +1895,7 @@ queuesmod__register_heap_types(PyObject *self, PyObject *args, PyObject *kwds) static PyMethodDef module_functions[] = { _INTERPQUEUES_CREATE_METHODDEF - {"destroy", _PyCFunction_CAST(queuesmod_destroy), - METH_VARARGS | METH_KEYWORDS, queuesmod_destroy_doc}, + _INTERPQUEUES_DESTROY_METHODDEF {"list_all", queuesmod_list_all, METH_NOARGS, queuesmod_list_all_doc}, {"put", _PyCFunction_CAST(queuesmod_put), diff --git a/Modules/clinic/_interpqueuesmodule.c.h b/Modules/clinic/_interpqueuesmodule.c.h index 21367c65f34cc6..bbe49dc7e6bab7 100644 --- a/Modules/clinic/_interpqueuesmodule.c.h +++ b/Modules/clinic/_interpqueuesmodule.c.h @@ -102,4 +102,66 @@ _interpqueues_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs, exit: return return_value; } -/*[clinic end generated code: output=ffb86a2fbab62e69 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_interpqueues_destroy__doc__, +"destroy($module, /, qid)\n" +"--\n" +"\n" +"Clear and destroy the queue.\n" +"\n" +"Afterward attempts to use the queue will behave as though it never existed."); + +#define _INTERPQUEUES_DESTROY_METHODDEF \ + {"destroy", _PyCFunction_CAST(_interpqueues_destroy), METH_FASTCALL|METH_KEYWORDS, _interpqueues_destroy__doc__}, + +static PyObject * +_interpqueues_destroy_impl(PyObject *module, qidarg_converter_data qidarg); + +static PyObject * +_interpqueues_destroy(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(qid), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"qid", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "destroy", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + qidarg_converter_data qidarg = {0}; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!qidarg_converter(args[0], &qidarg)) { + goto exit; + } + return_value = _interpqueues_destroy_impl(module, qidarg); + +exit: + return return_value; +} +/*[clinic end generated code: output=5458f3e41a6b8650 input=a9049054013a1b77]*/ From 616ca56fced57e9b320489ed1475ceb0f9c54319 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 17:48:59 +0100 Subject: [PATCH 03/16] Convert _interpqueues.list_all() --- Modules/_interpqueuesmodule.c | 20 +++++++++++--------- Modules/clinic/_interpqueuesmodule.c.h | 22 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Modules/_interpqueuesmodule.c b/Modules/_interpqueuesmodule.c index 20553cedb447ce..c19e59507a071b 100644 --- a/Modules/_interpqueuesmodule.c +++ b/Modules/_interpqueuesmodule.c @@ -1569,8 +1569,17 @@ _interpqueues_destroy_impl(PyObject *module, qidarg_converter_data qidarg) Py_RETURN_NONE; } +/*[clinic input] +_interpqueues.list_all + +Return the list of IDs for all queues. + +Each corresponding default unbound op and fallback is also included. +[clinic start generated code]*/ + static PyObject * -queuesmod_list_all(PyObject *self, PyObject *Py_UNUSED(ignored)) +_interpqueues_list_all_impl(PyObject *module) +/*[clinic end generated code: output=974280cb6442afdb input=ff9339d6385ed8ef]*/ { int64_t count = 0; struct queue_id_and_info *qids = _queues_list_all(&_globals.queues, &count); @@ -1601,12 +1610,6 @@ queuesmod_list_all(PyObject *self, PyObject *Py_UNUSED(ignored)) return ids; } -PyDoc_STRVAR(queuesmod_list_all_doc, -"list_all() -> [(qid, unboundop, fallback)]\n\ -\n\ -Return the list of IDs for all queues.\n\ -Each corresponding default unbound op and fallback is also included."); - static PyObject * queuesmod_put(PyObject *self, PyObject *args, PyObject *kwds) { @@ -1896,8 +1899,7 @@ queuesmod__register_heap_types(PyObject *self, PyObject *args, PyObject *kwds) static PyMethodDef module_functions[] = { _INTERPQUEUES_CREATE_METHODDEF _INTERPQUEUES_DESTROY_METHODDEF - {"list_all", queuesmod_list_all, - METH_NOARGS, queuesmod_list_all_doc}, + _INTERPQUEUES_LIST_ALL_METHODDEF {"put", _PyCFunction_CAST(queuesmod_put), METH_VARARGS | METH_KEYWORDS, queuesmod_put_doc}, {"get", _PyCFunction_CAST(queuesmod_get), diff --git a/Modules/clinic/_interpqueuesmodule.c.h b/Modules/clinic/_interpqueuesmodule.c.h index bbe49dc7e6bab7..f3e98f4944352e 100644 --- a/Modules/clinic/_interpqueuesmodule.c.h +++ b/Modules/clinic/_interpqueuesmodule.c.h @@ -164,4 +164,24 @@ _interpqueues_destroy(PyObject *module, PyObject *const *args, Py_ssize_t nargs, exit: return return_value; } -/*[clinic end generated code: output=5458f3e41a6b8650 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_interpqueues_list_all__doc__, +"list_all($module, /)\n" +"--\n" +"\n" +"Return the list of IDs for all queues.\n" +"\n" +"Each corresponding default unbound op and fallback is also included."); + +#define _INTERPQUEUES_LIST_ALL_METHODDEF \ + {"list_all", (PyCFunction)_interpqueues_list_all, METH_NOARGS, _interpqueues_list_all__doc__}, + +static PyObject * +_interpqueues_list_all_impl(PyObject *module); + +static PyObject * +_interpqueues_list_all(PyObject *module, PyObject *Py_UNUSED(ignored)) +{ + return _interpqueues_list_all_impl(module); +} +/*[clinic end generated code: output=700d27c8f5e2eb72 input=a9049054013a1b77]*/ From 4432216191dfff652067f99f2e2b1ff5affcbb6b Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 17:51:33 +0100 Subject: [PATCH 04/16] Convert _interpqueues.put() --- Modules/_interpqueuesmodule.c | 37 +++++------ Modules/clinic/_interpqueuesmodule.c.h | 85 +++++++++++++++++++++++++- 2 files changed, 100 insertions(+), 22 deletions(-) diff --git a/Modules/_interpqueuesmodule.c b/Modules/_interpqueuesmodule.c index c19e59507a071b..63543612ab4c95 100644 --- a/Modules/_interpqueuesmodule.c +++ b/Modules/_interpqueuesmodule.c @@ -1610,25 +1610,26 @@ _interpqueues_list_all_impl(PyObject *module) return ids; } +/*[clinic input] +_interpqueues.put + qid as qidarg: qidarg + obj: object + unboundop as unboundarg: int = -1 + fallback as fallbackarg: int = -1 + +Add the object's data to the queue. +[clinic start generated code]*/ + static PyObject * -queuesmod_put(PyObject *self, PyObject *args, PyObject *kwds) +_interpqueues_put_impl(PyObject *module, qidarg_converter_data qidarg, + PyObject *obj, int unboundarg, int fallbackarg) +/*[clinic end generated code: output=24c24c63489a19fa input=5cdee664acd659ce]*/ { - static char *kwlist[] = {"qid", "obj", "unboundop", "fallback", NULL}; - qidarg_converter_data qidarg = {0}; - PyObject *obj; - int unboundarg = -1; - int fallbackarg = -1; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&O|ii$p:put", kwlist, - qidarg_converter, &qidarg, &obj, - &unboundarg, &fallbackarg)) - { - return NULL; - } int64_t qid = qidarg.id; struct _queuedefaults defaults = {-1, -1}; if (unboundarg < 0 || fallbackarg < 0) { int err = queue_get_defaults(&_globals.queues, qid, &defaults); - if (handle_queue_error(err, self, qid)) { + if (handle_queue_error(err, module, qid)) { return NULL; } } @@ -1644,18 +1645,13 @@ queuesmod_put(PyObject *self, PyObject *args, PyObject *kwds) /* Queue up the object. */ int err = queue_put(&_globals.queues, qid, obj, unboundop, fallback); // This is the only place that raises QueueFull. - if (handle_queue_error(err, self, qid)) { + if (handle_queue_error(err, module, qid)) { return NULL; } Py_RETURN_NONE; } -PyDoc_STRVAR(queuesmod_put_doc, -"put(qid, obj)\n\ -\n\ -Add the object's data to the queue."); - static PyObject * queuesmod_get(PyObject *self, PyObject *args, PyObject *kwds) { @@ -1900,8 +1896,7 @@ static PyMethodDef module_functions[] = { _INTERPQUEUES_CREATE_METHODDEF _INTERPQUEUES_DESTROY_METHODDEF _INTERPQUEUES_LIST_ALL_METHODDEF - {"put", _PyCFunction_CAST(queuesmod_put), - METH_VARARGS | METH_KEYWORDS, queuesmod_put_doc}, + _INTERPQUEUES_PUT_METHODDEF {"get", _PyCFunction_CAST(queuesmod_get), METH_VARARGS | METH_KEYWORDS, queuesmod_get_doc}, {"bind", _PyCFunction_CAST(queuesmod_bind), diff --git a/Modules/clinic/_interpqueuesmodule.c.h b/Modules/clinic/_interpqueuesmodule.c.h index f3e98f4944352e..f58f8489b17368 100644 --- a/Modules/clinic/_interpqueuesmodule.c.h +++ b/Modules/clinic/_interpqueuesmodule.c.h @@ -184,4 +184,87 @@ _interpqueues_list_all(PyObject *module, PyObject *Py_UNUSED(ignored)) { return _interpqueues_list_all_impl(module); } -/*[clinic end generated code: output=700d27c8f5e2eb72 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_interpqueues_put__doc__, +"put($module, /, qid, obj, unboundop=-1, fallback=-1)\n" +"--\n" +"\n" +"Add the object\'s data to the queue."); + +#define _INTERPQUEUES_PUT_METHODDEF \ + {"put", _PyCFunction_CAST(_interpqueues_put), METH_FASTCALL|METH_KEYWORDS, _interpqueues_put__doc__}, + +static PyObject * +_interpqueues_put_impl(PyObject *module, qidarg_converter_data qidarg, + PyObject *obj, int unboundarg, int fallbackarg); + +static PyObject * +_interpqueues_put(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 4 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(qid), &_Py_ID(obj), &_Py_ID(unboundop), &_Py_ID(fallback), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"qid", "obj", "unboundop", "fallback", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "put", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[4]; + Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; + qidarg_converter_data qidarg = {0}; + PyObject *obj; + int unboundarg = -1; + int fallbackarg = -1; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 2, /*maxpos*/ 4, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!qidarg_converter(args[0], &qidarg)) { + goto exit; + } + obj = args[1]; + if (!noptargs) { + goto skip_optional_pos; + } + if (args[2]) { + unboundarg = PyLong_AsInt(args[2]); + if (unboundarg == -1 && PyErr_Occurred()) { + goto exit; + } + if (!--noptargs) { + goto skip_optional_pos; + } + } + fallbackarg = PyLong_AsInt(args[3]); + if (fallbackarg == -1 && PyErr_Occurred()) { + goto exit; + } +skip_optional_pos: + return_value = _interpqueues_put_impl(module, qidarg, obj, unboundarg, fallbackarg); + +exit: + return return_value; +} +/*[clinic end generated code: output=e56010c88d411c5a input=a9049054013a1b77]*/ From 214ab304793909e1986a101d8f9042fd2eb1fcbc Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 17:53:18 +0100 Subject: [PATCH 05/16] Convert _interpqueues.get() --- Modules/_interpqueuesmodule.c | 32 ++++++------- Modules/clinic/_interpqueuesmodule.c.h | 65 +++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 19 deletions(-) diff --git a/Modules/_interpqueuesmodule.c b/Modules/_interpqueuesmodule.c index 63543612ab4c95..b7e8080393fb7e 100644 --- a/Modules/_interpqueuesmodule.c +++ b/Modules/_interpqueuesmodule.c @@ -1652,22 +1652,27 @@ _interpqueues_put_impl(PyObject *module, qidarg_converter_data qidarg, Py_RETURN_NONE; } +/*[clinic input] +_interpqueues.get + qid as qidarg: qidarg + +Return a new object from the data at the front of the queue. + +The unbound op is also returned. +If there is nothing to receive then raise QueueEmpty. +[clinic start generated code]*/ + static PyObject * -queuesmod_get(PyObject *self, PyObject *args, PyObject *kwds) +_interpqueues_get_impl(PyObject *module, qidarg_converter_data qidarg) +/*[clinic end generated code: output=39fc769d4921e857 input=ba7ffbfb10eaacc8]*/ { - static char *kwlist[] = {"qid", NULL}; - qidarg_converter_data qidarg = {0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&:get", kwlist, - qidarg_converter, &qidarg)) { - return NULL; - } int64_t qid = qidarg.id; PyObject *obj = NULL; int unboundop = 0; int err = queue_get(&_globals.queues, qid, &obj, &unboundop); // This is the only place that raises QueueEmpty. - if (handle_queue_error(err, self, qid)) { + if (handle_queue_error(err, module, qid)) { return NULL; } @@ -1679,14 +1684,6 @@ queuesmod_get(PyObject *self, PyObject *args, PyObject *kwds) return res; } -PyDoc_STRVAR(queuesmod_get_doc, -"get(qid) -> (obj, unboundop)\n\ -\n\ -Return a new object from the data at the front of the queue.\n\ -The unbound op is also returned.\n\ -\n\ -If there is nothing to receive then raise QueueEmpty."); - static PyObject * queuesmod_bind(PyObject *self, PyObject *args, PyObject *kwds) { @@ -1897,8 +1894,7 @@ static PyMethodDef module_functions[] = { _INTERPQUEUES_DESTROY_METHODDEF _INTERPQUEUES_LIST_ALL_METHODDEF _INTERPQUEUES_PUT_METHODDEF - {"get", _PyCFunction_CAST(queuesmod_get), - METH_VARARGS | METH_KEYWORDS, queuesmod_get_doc}, + _INTERPQUEUES_GET_METHODDEF {"bind", _PyCFunction_CAST(queuesmod_bind), METH_VARARGS | METH_KEYWORDS, queuesmod_bind_doc}, {"release", _PyCFunction_CAST(queuesmod_release), diff --git a/Modules/clinic/_interpqueuesmodule.c.h b/Modules/clinic/_interpqueuesmodule.c.h index f58f8489b17368..1b769b624dabee 100644 --- a/Modules/clinic/_interpqueuesmodule.c.h +++ b/Modules/clinic/_interpqueuesmodule.c.h @@ -267,4 +267,67 @@ _interpqueues_put(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyO exit: return return_value; } -/*[clinic end generated code: output=e56010c88d411c5a input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_interpqueues_get__doc__, +"get($module, /, qid)\n" +"--\n" +"\n" +"Return a new object from the data at the front of the queue.\n" +"\n" +"The unbound op is also returned.\n" +"If there is nothing to receive then raise QueueEmpty."); + +#define _INTERPQUEUES_GET_METHODDEF \ + {"get", _PyCFunction_CAST(_interpqueues_get), METH_FASTCALL|METH_KEYWORDS, _interpqueues_get__doc__}, + +static PyObject * +_interpqueues_get_impl(PyObject *module, qidarg_converter_data qidarg); + +static PyObject * +_interpqueues_get(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(qid), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"qid", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "get", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + qidarg_converter_data qidarg = {0}; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!qidarg_converter(args[0], &qidarg)) { + goto exit; + } + return_value = _interpqueues_get_impl(module, qidarg); + +exit: + return return_value; +} +/*[clinic end generated code: output=70d45746a98a2b08 input=a9049054013a1b77]*/ From cdafcd80e9c74adfcb3b4c9acb678f680adc40a6 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 17:54:46 +0100 Subject: [PATCH 06/16] Convert _interpqueues.bind() --- Modules/_interpqueuesmodule.c | 29 ++++++------ Modules/clinic/_interpqueuesmodule.c.h | 64 +++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 17 deletions(-) diff --git a/Modules/_interpqueuesmodule.c b/Modules/_interpqueuesmodule.c index b7e8080393fb7e..a1281e603472a6 100644 --- a/Modules/_interpqueuesmodule.c +++ b/Modules/_interpqueuesmodule.c @@ -1684,21 +1684,25 @@ _interpqueues_get_impl(PyObject *module, qidarg_converter_data qidarg) return res; } +/*[clinic input] +_interpqueues.bind + qid as qidarg: qidarg + +Take a reference to the identified queue. + +The queue is not destroyed until there are no references left. +[clinic start generated code]*/ + static PyObject * -queuesmod_bind(PyObject *self, PyObject *args, PyObject *kwds) +_interpqueues_bind_impl(PyObject *module, qidarg_converter_data qidarg) +/*[clinic end generated code: output=88ef140ddff25e90 input=3c96a605f31ba766]*/ { - static char *kwlist[] = {"qid", NULL}; - qidarg_converter_data qidarg = {0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&:bind", kwlist, - qidarg_converter, &qidarg)) { - return NULL; - } int64_t qid = qidarg.id; // XXX Check module state if bound already. int err = _queues_incref(&_globals.queues, qid); - if (handle_queue_error(err, self, qid)) { + if (handle_queue_error(err, module, qid)) { return NULL; } @@ -1707,12 +1711,6 @@ queuesmod_bind(PyObject *self, PyObject *args, PyObject *kwds) Py_RETURN_NONE; } -PyDoc_STRVAR(queuesmod_bind_doc, -"bind(qid)\n\ -\n\ -Take a reference to the identified queue.\n\ -The queue is not destroyed until there are no references left."); - static PyObject * queuesmod_release(PyObject *self, PyObject *args, PyObject *kwds) { @@ -1895,8 +1893,7 @@ static PyMethodDef module_functions[] = { _INTERPQUEUES_LIST_ALL_METHODDEF _INTERPQUEUES_PUT_METHODDEF _INTERPQUEUES_GET_METHODDEF - {"bind", _PyCFunction_CAST(queuesmod_bind), - METH_VARARGS | METH_KEYWORDS, queuesmod_bind_doc}, + _INTERPQUEUES_BIND_METHODDEF {"release", _PyCFunction_CAST(queuesmod_release), METH_VARARGS | METH_KEYWORDS, queuesmod_release_doc}, {"get_maxsize", _PyCFunction_CAST(queuesmod_get_maxsize), diff --git a/Modules/clinic/_interpqueuesmodule.c.h b/Modules/clinic/_interpqueuesmodule.c.h index 1b769b624dabee..962130740dd1ba 100644 --- a/Modules/clinic/_interpqueuesmodule.c.h +++ b/Modules/clinic/_interpqueuesmodule.c.h @@ -330,4 +330,66 @@ _interpqueues_get(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyO exit: return return_value; } -/*[clinic end generated code: output=70d45746a98a2b08 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_interpqueues_bind__doc__, +"bind($module, /, qid)\n" +"--\n" +"\n" +"Take a reference to the identified queue.\n" +"\n" +"The queue is not destroyed until there are no references left."); + +#define _INTERPQUEUES_BIND_METHODDEF \ + {"bind", _PyCFunction_CAST(_interpqueues_bind), METH_FASTCALL|METH_KEYWORDS, _interpqueues_bind__doc__}, + +static PyObject * +_interpqueues_bind_impl(PyObject *module, qidarg_converter_data qidarg); + +static PyObject * +_interpqueues_bind(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(qid), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"qid", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "bind", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + qidarg_converter_data qidarg = {0}; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!qidarg_converter(args[0], &qidarg)) { + goto exit; + } + return_value = _interpqueues_bind_impl(module, qidarg); + +exit: + return return_value; +} +/*[clinic end generated code: output=017fa8ddaf5cfcfd input=a9049054013a1b77]*/ From ae9ee89ecf6ddea70bd99186c6a5b2630d41ae8f Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 17:55:53 +0100 Subject: [PATCH 07/16] Convert _interpqueues.release() --- Modules/_interpqueuesmodule.c | 30 ++++++------ Modules/clinic/_interpqueuesmodule.c.h | 64 +++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 18 deletions(-) diff --git a/Modules/_interpqueuesmodule.c b/Modules/_interpqueuesmodule.c index a1281e603472a6..84f99532292e73 100644 --- a/Modules/_interpqueuesmodule.c +++ b/Modules/_interpqueuesmodule.c @@ -1711,36 +1711,33 @@ _interpqueues_bind_impl(PyObject *module, qidarg_converter_data qidarg) Py_RETURN_NONE; } +/*[clinic input] +_interpqueues.release + qid as qidarg: qidarg + +Release a reference to the queue. + +The queue is destroyed once there are no references left. +[clinic start generated code]*/ + static PyObject * -queuesmod_release(PyObject *self, PyObject *args, PyObject *kwds) +_interpqueues_release_impl(PyObject *module, qidarg_converter_data qidarg) +/*[clinic end generated code: output=53a0180f7f311387 input=57923b1efa4772b5]*/ { // Note that only the current interpreter is affected. - static char *kwlist[] = {"qid", NULL}; - qidarg_converter_data qidarg = {0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, - "O&:release", kwlist, - qidarg_converter, &qidarg)) { - return NULL; - } int64_t qid = qidarg.id; // XXX Check module state if bound already. // XXX Update module state. int err = _queues_decref(&_globals.queues, qid); - if (handle_queue_error(err, self, qid)) { + if (handle_queue_error(err, module, qid)) { return NULL; } Py_RETURN_NONE; } -PyDoc_STRVAR(queuesmod_release_doc, -"release(qid)\n\ -\n\ -Release a reference to the queue.\n\ -The queue is destroyed once there are no references left."); - static PyObject * queuesmod_get_maxsize(PyObject *self, PyObject *args, PyObject *kwds) { @@ -1894,8 +1891,7 @@ static PyMethodDef module_functions[] = { _INTERPQUEUES_PUT_METHODDEF _INTERPQUEUES_GET_METHODDEF _INTERPQUEUES_BIND_METHODDEF - {"release", _PyCFunction_CAST(queuesmod_release), - METH_VARARGS | METH_KEYWORDS, queuesmod_release_doc}, + _INTERPQUEUES_RELEASE_METHODDEF {"get_maxsize", _PyCFunction_CAST(queuesmod_get_maxsize), METH_VARARGS | METH_KEYWORDS, queuesmod_get_maxsize_doc}, {"get_queue_defaults", _PyCFunction_CAST(queuesmod_get_queue_defaults), diff --git a/Modules/clinic/_interpqueuesmodule.c.h b/Modules/clinic/_interpqueuesmodule.c.h index 962130740dd1ba..873b63d4fd699f 100644 --- a/Modules/clinic/_interpqueuesmodule.c.h +++ b/Modules/clinic/_interpqueuesmodule.c.h @@ -392,4 +392,66 @@ _interpqueues_bind(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py exit: return return_value; } -/*[clinic end generated code: output=017fa8ddaf5cfcfd input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_interpqueues_release__doc__, +"release($module, /, qid)\n" +"--\n" +"\n" +"Release a reference to the queue.\n" +"\n" +"The queue is destroyed once there are no references left."); + +#define _INTERPQUEUES_RELEASE_METHODDEF \ + {"release", _PyCFunction_CAST(_interpqueues_release), METH_FASTCALL|METH_KEYWORDS, _interpqueues_release__doc__}, + +static PyObject * +_interpqueues_release_impl(PyObject *module, qidarg_converter_data qidarg); + +static PyObject * +_interpqueues_release(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(qid), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"qid", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "release", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + qidarg_converter_data qidarg = {0}; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!qidarg_converter(args[0], &qidarg)) { + goto exit; + } + return_value = _interpqueues_release_impl(module, qidarg); + +exit: + return return_value; +} +/*[clinic end generated code: output=514e98d441994baa input=a9049054013a1b77]*/ From 3b8bf4880e3581b189aabf78728f0189bb5214fa Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 18:05:43 +0100 Subject: [PATCH 08/16] Convert _interpqueues.get_maxsize() --- Modules/_interpqueuesmodule.c | 28 +++++------- Modules/clinic/_interpqueuesmodule.c.h | 63 +++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 17 deletions(-) diff --git a/Modules/_interpqueuesmodule.c b/Modules/_interpqueuesmodule.c index 84f99532292e73..5a779fc95655cb 100644 --- a/Modules/_interpqueuesmodule.c +++ b/Modules/_interpqueuesmodule.c @@ -1738,31 +1738,28 @@ _interpqueues_release_impl(PyObject *module, qidarg_converter_data qidarg) Py_RETURN_NONE; } +/*[clinic input] +_interpqueues.get_maxsize + qid as qidarg: qidarg + +Return the maximum number of items in the queue. +[clinic start generated code]*/ + static PyObject * -queuesmod_get_maxsize(PyObject *self, PyObject *args, PyObject *kwds) +_interpqueues_get_maxsize_impl(PyObject *module, + qidarg_converter_data qidarg) +/*[clinic end generated code: output=6cefdf97233e62d2 input=0e217353c6384add]*/ { - static char *kwlist[] = {"qid", NULL}; - qidarg_converter_data qidarg = {0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, - "O&:get_maxsize", kwlist, - qidarg_converter, &qidarg)) { - return NULL; - } int64_t qid = qidarg.id; Py_ssize_t maxsize = -1; int err = queue_get_maxsize(&_globals.queues, qid, &maxsize); - if (handle_queue_error(err, self, qid)) { + if (handle_queue_error(err, module, qid)) { return NULL; } return PyLong_FromLongLong(maxsize); } -PyDoc_STRVAR(queuesmod_get_maxsize_doc, -"get_maxsize(qid)\n\ -\n\ -Return the maximum number of items in the queue."); - static PyObject * queuesmod_get_queue_defaults(PyObject *self, PyObject *args, PyObject *kwds) { @@ -1892,8 +1889,7 @@ static PyMethodDef module_functions[] = { _INTERPQUEUES_GET_METHODDEF _INTERPQUEUES_BIND_METHODDEF _INTERPQUEUES_RELEASE_METHODDEF - {"get_maxsize", _PyCFunction_CAST(queuesmod_get_maxsize), - METH_VARARGS | METH_KEYWORDS, queuesmod_get_maxsize_doc}, + _INTERPQUEUES_GET_MAXSIZE_METHODDEF {"get_queue_defaults", _PyCFunction_CAST(queuesmod_get_queue_defaults), METH_VARARGS | METH_KEYWORDS, queuesmod_get_queue_defaults_doc}, {"is_full", _PyCFunction_CAST(queuesmod_is_full), diff --git a/Modules/clinic/_interpqueuesmodule.c.h b/Modules/clinic/_interpqueuesmodule.c.h index 873b63d4fd699f..023ec6906aaab1 100644 --- a/Modules/clinic/_interpqueuesmodule.c.h +++ b/Modules/clinic/_interpqueuesmodule.c.h @@ -454,4 +454,65 @@ _interpqueues_release(PyObject *module, PyObject *const *args, Py_ssize_t nargs, exit: return return_value; } -/*[clinic end generated code: output=514e98d441994baa input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_interpqueues_get_maxsize__doc__, +"get_maxsize($module, /, qid)\n" +"--\n" +"\n" +"Return the maximum number of items in the queue."); + +#define _INTERPQUEUES_GET_MAXSIZE_METHODDEF \ + {"get_maxsize", _PyCFunction_CAST(_interpqueues_get_maxsize), METH_FASTCALL|METH_KEYWORDS, _interpqueues_get_maxsize__doc__}, + +static PyObject * +_interpqueues_get_maxsize_impl(PyObject *module, + qidarg_converter_data qidarg); + +static PyObject * +_interpqueues_get_maxsize(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(qid), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"qid", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "get_maxsize", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + qidarg_converter_data qidarg = {0}; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!qidarg_converter(args[0], &qidarg)) { + goto exit; + } + return_value = _interpqueues_get_maxsize_impl(module, qidarg); + +exit: + return return_value; +} +/*[clinic end generated code: output=dc66bbc1b612c412 input=a9049054013a1b77]*/ From 822b206faf7a1a468e497580832eecd93002fcb1 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 18:07:48 +0100 Subject: [PATCH 09/16] Convert _interpqueues.get_queue_defaults() --- Modules/_interpqueuesmodule.c | 28 +++++------- Modules/clinic/_interpqueuesmodule.c.h | 63 +++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 17 deletions(-) diff --git a/Modules/_interpqueuesmodule.c b/Modules/_interpqueuesmodule.c index 5a779fc95655cb..77ab932d1e123d 100644 --- a/Modules/_interpqueuesmodule.c +++ b/Modules/_interpqueuesmodule.c @@ -1760,21 +1760,23 @@ _interpqueues_get_maxsize_impl(PyObject *module, return PyLong_FromLongLong(maxsize); } +/*[clinic input] +_interpqueues.get_queue_defaults + qid as qidarg: qidarg + +Return the queue's default values, set when it was created. +[clinic start generated code]*/ + static PyObject * -queuesmod_get_queue_defaults(PyObject *self, PyObject *args, PyObject *kwds) +_interpqueues_get_queue_defaults_impl(PyObject *module, + qidarg_converter_data qidarg) +/*[clinic end generated code: output=b43920b9ad7d2a82 input=be70c4d4f09ba78a]*/ { - static char *kwlist[] = {"qid", NULL}; - qidarg_converter_data qidarg = {0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, - "O&:get_queue_defaults", kwlist, - qidarg_converter, &qidarg)) { - return NULL; - } int64_t qid = qidarg.id; struct _queuedefaults defaults = {0}; int err = queue_get_defaults(&_globals.queues, qid, &defaults); - if (handle_queue_error(err, self, qid)) { + if (handle_queue_error(err, module, qid)) { return NULL; } @@ -1782,11 +1784,6 @@ queuesmod_get_queue_defaults(PyObject *self, PyObject *args, PyObject *kwds) return res; } -PyDoc_STRVAR(queuesmod_get_queue_defaults_doc, -"get_queue_defaults(qid)\n\ -\n\ -Return the queue's default values, set when it was created."); - static PyObject * queuesmod_is_full(PyObject *self, PyObject *args, PyObject *kwds) { @@ -1890,8 +1887,7 @@ static PyMethodDef module_functions[] = { _INTERPQUEUES_BIND_METHODDEF _INTERPQUEUES_RELEASE_METHODDEF _INTERPQUEUES_GET_MAXSIZE_METHODDEF - {"get_queue_defaults", _PyCFunction_CAST(queuesmod_get_queue_defaults), - METH_VARARGS | METH_KEYWORDS, queuesmod_get_queue_defaults_doc}, + _INTERPQUEUES_GET_QUEUE_DEFAULTS_METHODDEF {"is_full", _PyCFunction_CAST(queuesmod_is_full), METH_VARARGS | METH_KEYWORDS, queuesmod_is_full_doc}, {"get_count", _PyCFunction_CAST(queuesmod_get_count), diff --git a/Modules/clinic/_interpqueuesmodule.c.h b/Modules/clinic/_interpqueuesmodule.c.h index 023ec6906aaab1..667e4704dd03e0 100644 --- a/Modules/clinic/_interpqueuesmodule.c.h +++ b/Modules/clinic/_interpqueuesmodule.c.h @@ -515,4 +515,65 @@ _interpqueues_get_maxsize(PyObject *module, PyObject *const *args, Py_ssize_t na exit: return return_value; } -/*[clinic end generated code: output=dc66bbc1b612c412 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_interpqueues_get_queue_defaults__doc__, +"get_queue_defaults($module, /, qid)\n" +"--\n" +"\n" +"Return the queue\'s default values, set when it was created."); + +#define _INTERPQUEUES_GET_QUEUE_DEFAULTS_METHODDEF \ + {"get_queue_defaults", _PyCFunction_CAST(_interpqueues_get_queue_defaults), METH_FASTCALL|METH_KEYWORDS, _interpqueues_get_queue_defaults__doc__}, + +static PyObject * +_interpqueues_get_queue_defaults_impl(PyObject *module, + qidarg_converter_data qidarg); + +static PyObject * +_interpqueues_get_queue_defaults(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(qid), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"qid", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "get_queue_defaults", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + qidarg_converter_data qidarg = {0}; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!qidarg_converter(args[0], &qidarg)) { + goto exit; + } + return_value = _interpqueues_get_queue_defaults_impl(module, qidarg); + +exit: + return return_value; +} +/*[clinic end generated code: output=934b40d0f6e02fbc input=a9049054013a1b77]*/ From 0a4d8f99310991920e8e4317732136e251310e33 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 18:09:15 +0100 Subject: [PATCH 10/16] Convert _interpqueues.is_full() --- Modules/_interpqueuesmodule.c | 27 +++++------ Modules/clinic/_interpqueuesmodule.c.h | 62 +++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 17 deletions(-) diff --git a/Modules/_interpqueuesmodule.c b/Modules/_interpqueuesmodule.c index 77ab932d1e123d..6b7937c36f02e1 100644 --- a/Modules/_interpqueuesmodule.c +++ b/Modules/_interpqueuesmodule.c @@ -1784,21 +1784,22 @@ _interpqueues_get_queue_defaults_impl(PyObject *module, return res; } +/*[clinic input] +_interpqueues.is_full + qid as qidarg: qidarg + +Return true if the queue has a maxsize and has reached it. +[clinic start generated code]*/ + static PyObject * -queuesmod_is_full(PyObject *self, PyObject *args, PyObject *kwds) +_interpqueues_is_full_impl(PyObject *module, qidarg_converter_data qidarg) +/*[clinic end generated code: output=a2867798f650ad6a input=ff1e367174db36e7]*/ { - static char *kwlist[] = {"qid", NULL}; - qidarg_converter_data qidarg = {0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, - "O&:is_full", kwlist, - qidarg_converter, &qidarg)) { - return NULL; - } int64_t qid = qidarg.id; int is_full = 0; int err = queue_is_full(&_globals.queues, qid, &is_full); - if (handle_queue_error(err, self, qid)) { + if (handle_queue_error(err, module, qid)) { return NULL; } if (is_full) { @@ -1807,11 +1808,6 @@ queuesmod_is_full(PyObject *self, PyObject *args, PyObject *kwds) Py_RETURN_FALSE; } -PyDoc_STRVAR(queuesmod_is_full_doc, -"is_full(qid)\n\ -\n\ -Return true if the queue has a maxsize and has reached it."); - static PyObject * queuesmod_get_count(PyObject *self, PyObject *args, PyObject *kwds) { @@ -1888,8 +1884,7 @@ static PyMethodDef module_functions[] = { _INTERPQUEUES_RELEASE_METHODDEF _INTERPQUEUES_GET_MAXSIZE_METHODDEF _INTERPQUEUES_GET_QUEUE_DEFAULTS_METHODDEF - {"is_full", _PyCFunction_CAST(queuesmod_is_full), - METH_VARARGS | METH_KEYWORDS, queuesmod_is_full_doc}, + _INTERPQUEUES_IS_FULL_METHODDEF {"get_count", _PyCFunction_CAST(queuesmod_get_count), METH_VARARGS | METH_KEYWORDS, queuesmod_get_count_doc}, {"_register_heap_types", _PyCFunction_CAST(queuesmod__register_heap_types), diff --git a/Modules/clinic/_interpqueuesmodule.c.h b/Modules/clinic/_interpqueuesmodule.c.h index 667e4704dd03e0..15c0dffe946502 100644 --- a/Modules/clinic/_interpqueuesmodule.c.h +++ b/Modules/clinic/_interpqueuesmodule.c.h @@ -576,4 +576,64 @@ _interpqueues_get_queue_defaults(PyObject *module, PyObject *const *args, Py_ssi exit: return return_value; } -/*[clinic end generated code: output=934b40d0f6e02fbc input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_interpqueues_is_full__doc__, +"is_full($module, /, qid)\n" +"--\n" +"\n" +"Return true if the queue has a maxsize and has reached it."); + +#define _INTERPQUEUES_IS_FULL_METHODDEF \ + {"is_full", _PyCFunction_CAST(_interpqueues_is_full), METH_FASTCALL|METH_KEYWORDS, _interpqueues_is_full__doc__}, + +static PyObject * +_interpqueues_is_full_impl(PyObject *module, qidarg_converter_data qidarg); + +static PyObject * +_interpqueues_is_full(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(qid), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"qid", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "is_full", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + qidarg_converter_data qidarg = {0}; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!qidarg_converter(args[0], &qidarg)) { + goto exit; + } + return_value = _interpqueues_is_full_impl(module, qidarg); + +exit: + return return_value; +} +/*[clinic end generated code: output=716511a7166dd2a3 input=a9049054013a1b77]*/ From ca68aa77abb32ab84d8adb29df7d6923d573f804 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 18:11:19 +0100 Subject: [PATCH 11/16] Convert _interpqueues.get_count() --- Modules/_interpqueuesmodule.c | 27 +++++------ Modules/clinic/_interpqueuesmodule.c.h | 62 +++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 17 deletions(-) diff --git a/Modules/_interpqueuesmodule.c b/Modules/_interpqueuesmodule.c index 6b7937c36f02e1..01031425faf34b 100644 --- a/Modules/_interpqueuesmodule.c +++ b/Modules/_interpqueuesmodule.c @@ -1808,32 +1808,28 @@ _interpqueues_is_full_impl(PyObject *module, qidarg_converter_data qidarg) Py_RETURN_FALSE; } +/*[clinic input] +_interpqueues.get_count + qid as qidarg: qidarg + +Return the number of items in the queue. +[clinic start generated code]*/ + static PyObject * -queuesmod_get_count(PyObject *self, PyObject *args, PyObject *kwds) +_interpqueues_get_count_impl(PyObject *module, qidarg_converter_data qidarg) +/*[clinic end generated code: output=df18967daf982771 input=2063e063d0cac8ea]*/ { - static char *kwlist[] = {"qid", NULL}; - qidarg_converter_data qidarg = {0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, - "O&:get_count", kwlist, - qidarg_converter, &qidarg)) { - return NULL; - } int64_t qid = qidarg.id; Py_ssize_t count = -1; int err = queue_get_count(&_globals.queues, qid, &count); - if (handle_queue_error(err, self, qid)) { + if (handle_queue_error(err, module, qid)) { return NULL; } assert(count >= 0); return PyLong_FromSsize_t(count); } -PyDoc_STRVAR(queuesmod_get_count_doc, -"get_count(qid)\n\ -\n\ -Return the number of items in the queue."); - static PyObject * queuesmod__register_heap_types(PyObject *self, PyObject *args, PyObject *kwds) { @@ -1885,8 +1881,7 @@ static PyMethodDef module_functions[] = { _INTERPQUEUES_GET_MAXSIZE_METHODDEF _INTERPQUEUES_GET_QUEUE_DEFAULTS_METHODDEF _INTERPQUEUES_IS_FULL_METHODDEF - {"get_count", _PyCFunction_CAST(queuesmod_get_count), - METH_VARARGS | METH_KEYWORDS, queuesmod_get_count_doc}, + _INTERPQUEUES_GET_COUNT_METHODDEF {"_register_heap_types", _PyCFunction_CAST(queuesmod__register_heap_types), METH_VARARGS | METH_KEYWORDS, NULL}, diff --git a/Modules/clinic/_interpqueuesmodule.c.h b/Modules/clinic/_interpqueuesmodule.c.h index 15c0dffe946502..a3385d06a9dd43 100644 --- a/Modules/clinic/_interpqueuesmodule.c.h +++ b/Modules/clinic/_interpqueuesmodule.c.h @@ -636,4 +636,64 @@ _interpqueues_is_full(PyObject *module, PyObject *const *args, Py_ssize_t nargs, exit: return return_value; } -/*[clinic end generated code: output=716511a7166dd2a3 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_interpqueues_get_count__doc__, +"get_count($module, /, qid)\n" +"--\n" +"\n" +"Return the number of items in the queue."); + +#define _INTERPQUEUES_GET_COUNT_METHODDEF \ + {"get_count", _PyCFunction_CAST(_interpqueues_get_count), METH_FASTCALL|METH_KEYWORDS, _interpqueues_get_count__doc__}, + +static PyObject * +_interpqueues_get_count_impl(PyObject *module, qidarg_converter_data qidarg); + +static PyObject * +_interpqueues_get_count(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 1 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(qid), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"qid", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "get_count", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[1]; + qidarg_converter_data qidarg = {0}; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + if (!qidarg_converter(args[0], &qidarg)) { + goto exit; + } + return_value = _interpqueues_get_count_impl(module, qidarg); + +exit: + return return_value; +} +/*[clinic end generated code: output=c803e09e44f9d471 input=a9049054013a1b77]*/ From 2fd1f9a0de79dff9d4cab8d4d3f756a66a390a3a Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 18:12:59 +0100 Subject: [PATCH 12/16] Convert _interpqueues._register_heap_types() --- Modules/_interpqueuesmodule.c | 31 ++++++------ Modules/clinic/_interpqueuesmodule.c.h | 67 +++++++++++++++++++++++++- 2 files changed, 83 insertions(+), 15 deletions(-) diff --git a/Modules/_interpqueuesmodule.c b/Modules/_interpqueuesmodule.c index 01031425faf34b..a9af24a6664450 100644 --- a/Modules/_interpqueuesmodule.c +++ b/Modules/_interpqueuesmodule.c @@ -1830,18 +1830,22 @@ _interpqueues_get_count_impl(PyObject *module, qidarg_converter_data qidarg) return PyLong_FromSsize_t(count); } +/*[clinic input] +_interpqueues._register_heap_types + queuetype: object + emptyerror: object + fullerror: object + +Return the number of items in the queue. +[clinic start generated code]*/ + static PyObject * -queuesmod__register_heap_types(PyObject *self, PyObject *args, PyObject *kwds) -{ - static char *kwlist[] = {"queuetype", "emptyerror", "fullerror", NULL}; - PyObject *queuetype; - PyObject *emptyerror; - PyObject *fullerror; - if (!PyArg_ParseTupleAndKeywords(args, kwds, - "OOO:_register_heap_types", kwlist, - &queuetype, &emptyerror, &fullerror)) { - return NULL; - } +_interpqueues__register_heap_types_impl(PyObject *module, + PyObject *queuetype, + PyObject *emptyerror, + PyObject *fullerror) +/*[clinic end generated code: output=8d7b129b64dcd01f input=878c5f97c09404bf]*/ +{ if (!PyType_Check(queuetype)) { PyErr_SetString(PyExc_TypeError, "expected a type for 'queuetype'"); @@ -1858,7 +1862,7 @@ queuesmod__register_heap_types(PyObject *self, PyObject *args, PyObject *kwds) return NULL; } - module_state *state = get_module_state(self); + module_state *state = get_module_state(module); if (set_external_queue_type(state, (PyTypeObject *)queuetype) < 0) { return NULL; @@ -1882,8 +1886,7 @@ static PyMethodDef module_functions[] = { _INTERPQUEUES_GET_QUEUE_DEFAULTS_METHODDEF _INTERPQUEUES_IS_FULL_METHODDEF _INTERPQUEUES_GET_COUNT_METHODDEF - {"_register_heap_types", _PyCFunction_CAST(queuesmod__register_heap_types), - METH_VARARGS | METH_KEYWORDS, NULL}, + _INTERPQUEUES__REGISTER_HEAP_TYPES_METHODDEF {NULL, NULL} /* sentinel */ }; diff --git a/Modules/clinic/_interpqueuesmodule.c.h b/Modules/clinic/_interpqueuesmodule.c.h index a3385d06a9dd43..4806aceb98e154 100644 --- a/Modules/clinic/_interpqueuesmodule.c.h +++ b/Modules/clinic/_interpqueuesmodule.c.h @@ -696,4 +696,69 @@ _interpqueues_get_count(PyObject *module, PyObject *const *args, Py_ssize_t narg exit: return return_value; } -/*[clinic end generated code: output=c803e09e44f9d471 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_interpqueues__register_heap_types__doc__, +"_register_heap_types($module, /, queuetype, emptyerror, fullerror)\n" +"--\n" +"\n" +"Return the number of items in the queue."); + +#define _INTERPQUEUES__REGISTER_HEAP_TYPES_METHODDEF \ + {"_register_heap_types", _PyCFunction_CAST(_interpqueues__register_heap_types), METH_FASTCALL|METH_KEYWORDS, _interpqueues__register_heap_types__doc__}, + +static PyObject * +_interpqueues__register_heap_types_impl(PyObject *module, + PyObject *queuetype, + PyObject *emptyerror, + PyObject *fullerror); + +static PyObject * +_interpqueues__register_heap_types(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) + + #define NUM_KEYWORDS 3 + static struct { + PyGC_Head _this_is_not_used; + PyObject_VAR_HEAD + Py_hash_t ob_hash; + PyObject *ob_item[NUM_KEYWORDS]; + } _kwtuple = { + .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) + .ob_hash = -1, + .ob_item = { &_Py_ID(queuetype), &_Py_ID(emptyerror), &_Py_ID(fullerror), }, + }; + #undef NUM_KEYWORDS + #define KWTUPLE (&_kwtuple.ob_base.ob_base) + + #else // !Py_BUILD_CORE + # define KWTUPLE NULL + #endif // !Py_BUILD_CORE + + static const char * const _keywords[] = {"queuetype", "emptyerror", "fullerror", NULL}; + static _PyArg_Parser _parser = { + .keywords = _keywords, + .fname = "_register_heap_types", + .kwtuple = KWTUPLE, + }; + #undef KWTUPLE + PyObject *argsbuf[3]; + PyObject *queuetype; + PyObject *emptyerror; + PyObject *fullerror; + + args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, + /*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); + if (!args) { + goto exit; + } + queuetype = args[0]; + emptyerror = args[1]; + fullerror = args[2]; + return_value = _interpqueues__register_heap_types_impl(module, queuetype, emptyerror, fullerror); + +exit: + return return_value; +} +/*[clinic end generated code: output=bda838d2c69fd3b4 input=a9049054013a1b77]*/ From 3cd5b3c20854e7fa0a2f3fd5a2ab2622b3d0fd2f Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 18:39:05 +0100 Subject: [PATCH 13/16] Improve qidarg_converter --- Modules/_interpqueuesmodule.c | 93 ++++++++++---------------- Modules/clinic/_interpqueuesmodule.c.h | 78 +++++++++++---------- 2 files changed, 75 insertions(+), 96 deletions(-) diff --git a/Modules/_interpqueuesmodule.c b/Modules/_interpqueuesmodule.c index a9af24a6664450..f6f98d3c877121 100644 --- a/Modules/_interpqueuesmodule.c +++ b/Modules/_interpqueuesmodule.c @@ -32,12 +32,11 @@ module _interpqueues /*[python input] class qidarg_converter(CConverter): - type = 'qidarg_converter_data' + type = 'int64_t' converter = 'qidarg_converter' - c_default='{0}' [python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=055fedf5dfa38d4d]*/ +/*[python end generated code: output=da39a3ee5e6b4b0d input=c64fbf36771164d6]*/ #define GLOBAL_MALLOC(TYPE) \ PyMem_RawMalloc(sizeof(TYPE)) @@ -1483,16 +1482,16 @@ clear_interpreter(void *data) } -typedef struct idarg_int64_converter_data qidarg_converter_data; - static int qidarg_converter(PyObject *arg, void *ptr) { - qidarg_converter_data *data = ptr; - if (data->label == NULL) { - data->label = "queue ID"; - } - return idarg_int64_converter(arg, ptr); + int64_t *qid_ptr = ptr; + struct idarg_int64_converter_data data = { + .label = "queue ID", + }; + int res = idarg_int64_converter(arg, &data); + *qid_ptr = data.id; + return res; } @@ -1549,7 +1548,7 @@ _interpqueues_create_impl(PyObject *module, Py_ssize_t maxsize, /*[clinic input] _interpqueues.destroy - qid as qidarg: qidarg + qid: qidarg Clear and destroy the queue. @@ -1557,11 +1556,9 @@ Afterward attempts to use the queue will behave as though it never existed. [clinic start generated code]*/ static PyObject * -_interpqueues_destroy_impl(PyObject *module, qidarg_converter_data qidarg) -/*[clinic end generated code: output=d362df720aded31a input=d77908b36282e0a2]*/ +_interpqueues_destroy_impl(PyObject *module, int64_t qid) +/*[clinic end generated code: output=46b35623f080cbff input=8632bba87f81e3e9]*/ { - int64_t qid = qidarg.id; - int err = queue_destroy(&_globals.queues, qid); if (handle_queue_error(err, module, qid)) { return NULL; @@ -1612,7 +1609,7 @@ _interpqueues_list_all_impl(PyObject *module) /*[clinic input] _interpqueues.put - qid as qidarg: qidarg + qid: qidarg obj: object unboundop as unboundarg: int = -1 fallback as fallbackarg: int = -1 @@ -1621,11 +1618,10 @@ Add the object's data to the queue. [clinic start generated code]*/ static PyObject * -_interpqueues_put_impl(PyObject *module, qidarg_converter_data qidarg, - PyObject *obj, int unboundarg, int fallbackarg) -/*[clinic end generated code: output=24c24c63489a19fa input=5cdee664acd659ce]*/ +_interpqueues_put_impl(PyObject *module, int64_t qid, PyObject *obj, + int unboundarg, int fallbackarg) +/*[clinic end generated code: output=2e0b31c6eaec29c9 input=4906550ab5c73be3]*/ { - int64_t qid = qidarg.id; struct _queuedefaults defaults = {-1, -1}; if (unboundarg < 0 || fallbackarg < 0) { int err = queue_get_defaults(&_globals.queues, qid, &defaults); @@ -1654,7 +1650,7 @@ _interpqueues_put_impl(PyObject *module, qidarg_converter_data qidarg, /*[clinic input] _interpqueues.get - qid as qidarg: qidarg + qid: qidarg Return a new object from the data at the front of the queue. @@ -1663,11 +1659,9 @@ If there is nothing to receive then raise QueueEmpty. [clinic start generated code]*/ static PyObject * -_interpqueues_get_impl(PyObject *module, qidarg_converter_data qidarg) -/*[clinic end generated code: output=39fc769d4921e857 input=ba7ffbfb10eaacc8]*/ +_interpqueues_get_impl(PyObject *module, int64_t qid) +/*[clinic end generated code: output=b0988a0e29194f05 input=73a70333af3b1c31]*/ { - int64_t qid = qidarg.id; - PyObject *obj = NULL; int unboundop = 0; int err = queue_get(&_globals.queues, qid, &obj, &unboundop); @@ -1686,7 +1680,7 @@ _interpqueues_get_impl(PyObject *module, qidarg_converter_data qidarg) /*[clinic input] _interpqueues.bind - qid as qidarg: qidarg + qid: qidarg Take a reference to the identified queue. @@ -1694,11 +1688,9 @@ The queue is not destroyed until there are no references left. [clinic start generated code]*/ static PyObject * -_interpqueues_bind_impl(PyObject *module, qidarg_converter_data qidarg) -/*[clinic end generated code: output=88ef140ddff25e90 input=3c96a605f31ba766]*/ +_interpqueues_bind_impl(PyObject *module, int64_t qid) +/*[clinic end generated code: output=02b515e203c3f926 input=b0efd1a6ce0e576e]*/ { - int64_t qid = qidarg.id; - // XXX Check module state if bound already. int err = _queues_incref(&_globals.queues, qid); @@ -1713,7 +1705,7 @@ _interpqueues_bind_impl(PyObject *module, qidarg_converter_data qidarg) /*[clinic input] _interpqueues.release - qid as qidarg: qidarg + qid: qidarg Release a reference to the queue. @@ -1721,11 +1713,10 @@ The queue is destroyed once there are no references left. [clinic start generated code]*/ static PyObject * -_interpqueues_release_impl(PyObject *module, qidarg_converter_data qidarg) -/*[clinic end generated code: output=53a0180f7f311387 input=57923b1efa4772b5]*/ +_interpqueues_release_impl(PyObject *module, int64_t qid) +/*[clinic end generated code: output=a59545d7c61fc6ee input=664125cf0262ff6f]*/ { // Note that only the current interpreter is affected. - int64_t qid = qidarg.id; // XXX Check module state if bound already. // XXX Update module state. @@ -1740,18 +1731,15 @@ _interpqueues_release_impl(PyObject *module, qidarg_converter_data qidarg) /*[clinic input] _interpqueues.get_maxsize - qid as qidarg: qidarg + qid: qidarg Return the maximum number of items in the queue. [clinic start generated code]*/ static PyObject * -_interpqueues_get_maxsize_impl(PyObject *module, - qidarg_converter_data qidarg) -/*[clinic end generated code: output=6cefdf97233e62d2 input=0e217353c6384add]*/ +_interpqueues_get_maxsize_impl(PyObject *module, int64_t qid) +/*[clinic end generated code: output=074202b9c6dc37bf input=ef55def3496cc379]*/ { - int64_t qid = qidarg.id; - Py_ssize_t maxsize = -1; int err = queue_get_maxsize(&_globals.queues, qid, &maxsize); if (handle_queue_error(err, module, qid)) { @@ -1762,18 +1750,15 @@ _interpqueues_get_maxsize_impl(PyObject *module, /*[clinic input] _interpqueues.get_queue_defaults - qid as qidarg: qidarg + qid: qidarg Return the queue's default values, set when it was created. [clinic start generated code]*/ static PyObject * -_interpqueues_get_queue_defaults_impl(PyObject *module, - qidarg_converter_data qidarg) -/*[clinic end generated code: output=b43920b9ad7d2a82 input=be70c4d4f09ba78a]*/ +_interpqueues_get_queue_defaults_impl(PyObject *module, int64_t qid) +/*[clinic end generated code: output=b1b8b8103834191a input=3102315a7bff77fc]*/ { - int64_t qid = qidarg.id; - struct _queuedefaults defaults = {0}; int err = queue_get_defaults(&_globals.queues, qid, &defaults); if (handle_queue_error(err, module, qid)) { @@ -1786,17 +1771,15 @@ _interpqueues_get_queue_defaults_impl(PyObject *module, /*[clinic input] _interpqueues.is_full - qid as qidarg: qidarg + qid: qidarg Return true if the queue has a maxsize and has reached it. [clinic start generated code]*/ static PyObject * -_interpqueues_is_full_impl(PyObject *module, qidarg_converter_data qidarg) -/*[clinic end generated code: output=a2867798f650ad6a input=ff1e367174db36e7]*/ +_interpqueues_is_full_impl(PyObject *module, int64_t qid) +/*[clinic end generated code: output=47a6e18477cddfee input=25d86a327ed3a2e7]*/ { - int64_t qid = qidarg.id; - int is_full = 0; int err = queue_is_full(&_globals.queues, qid, &is_full); if (handle_queue_error(err, module, qid)) { @@ -1810,17 +1793,15 @@ _interpqueues_is_full_impl(PyObject *module, qidarg_converter_data qidarg) /*[clinic input] _interpqueues.get_count - qid as qidarg: qidarg + qid: qidarg Return the number of items in the queue. [clinic start generated code]*/ static PyObject * -_interpqueues_get_count_impl(PyObject *module, qidarg_converter_data qidarg) -/*[clinic end generated code: output=df18967daf982771 input=2063e063d0cac8ea]*/ +_interpqueues_get_count_impl(PyObject *module, int64_t qid) +/*[clinic end generated code: output=fb9e66e829cdd964 input=ce47690e7598884b]*/ { - int64_t qid = qidarg.id; - Py_ssize_t count = -1; int err = queue_get_count(&_globals.queues, qid, &count); if (handle_queue_error(err, module, qid)) { diff --git a/Modules/clinic/_interpqueuesmodule.c.h b/Modules/clinic/_interpqueuesmodule.c.h index 4806aceb98e154..85671e42f1ba71 100644 --- a/Modules/clinic/_interpqueuesmodule.c.h +++ b/Modules/clinic/_interpqueuesmodule.c.h @@ -115,7 +115,7 @@ PyDoc_STRVAR(_interpqueues_destroy__doc__, {"destroy", _PyCFunction_CAST(_interpqueues_destroy), METH_FASTCALL|METH_KEYWORDS, _interpqueues_destroy__doc__}, static PyObject * -_interpqueues_destroy_impl(PyObject *module, qidarg_converter_data qidarg); +_interpqueues_destroy_impl(PyObject *module, int64_t qid); static PyObject * _interpqueues_destroy(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) @@ -149,17 +149,17 @@ _interpqueues_destroy(PyObject *module, PyObject *const *args, Py_ssize_t nargs, }; #undef KWTUPLE PyObject *argsbuf[1]; - qidarg_converter_data qidarg = {0}; + int64_t qid; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!args) { goto exit; } - if (!qidarg_converter(args[0], &qidarg)) { + if (!qidarg_converter(args[0], &qid)) { goto exit; } - return_value = _interpqueues_destroy_impl(module, qidarg); + return_value = _interpqueues_destroy_impl(module, qid); exit: return return_value; @@ -195,8 +195,8 @@ PyDoc_STRVAR(_interpqueues_put__doc__, {"put", _PyCFunction_CAST(_interpqueues_put), METH_FASTCALL|METH_KEYWORDS, _interpqueues_put__doc__}, static PyObject * -_interpqueues_put_impl(PyObject *module, qidarg_converter_data qidarg, - PyObject *obj, int unboundarg, int fallbackarg); +_interpqueues_put_impl(PyObject *module, int64_t qid, PyObject *obj, + int unboundarg, int fallbackarg); static PyObject * _interpqueues_put(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) @@ -231,7 +231,7 @@ _interpqueues_put(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyO #undef KWTUPLE PyObject *argsbuf[4]; Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; - qidarg_converter_data qidarg = {0}; + int64_t qid; PyObject *obj; int unboundarg = -1; int fallbackarg = -1; @@ -241,7 +241,7 @@ _interpqueues_put(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyO if (!args) { goto exit; } - if (!qidarg_converter(args[0], &qidarg)) { + if (!qidarg_converter(args[0], &qid)) { goto exit; } obj = args[1]; @@ -262,7 +262,7 @@ _interpqueues_put(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyO goto exit; } skip_optional_pos: - return_value = _interpqueues_put_impl(module, qidarg, obj, unboundarg, fallbackarg); + return_value = _interpqueues_put_impl(module, qid, obj, unboundarg, fallbackarg); exit: return return_value; @@ -281,7 +281,7 @@ PyDoc_STRVAR(_interpqueues_get__doc__, {"get", _PyCFunction_CAST(_interpqueues_get), METH_FASTCALL|METH_KEYWORDS, _interpqueues_get__doc__}, static PyObject * -_interpqueues_get_impl(PyObject *module, qidarg_converter_data qidarg); +_interpqueues_get_impl(PyObject *module, int64_t qid); static PyObject * _interpqueues_get(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) @@ -315,17 +315,17 @@ _interpqueues_get(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyO }; #undef KWTUPLE PyObject *argsbuf[1]; - qidarg_converter_data qidarg = {0}; + int64_t qid; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!args) { goto exit; } - if (!qidarg_converter(args[0], &qidarg)) { + if (!qidarg_converter(args[0], &qid)) { goto exit; } - return_value = _interpqueues_get_impl(module, qidarg); + return_value = _interpqueues_get_impl(module, qid); exit: return return_value; @@ -343,7 +343,7 @@ PyDoc_STRVAR(_interpqueues_bind__doc__, {"bind", _PyCFunction_CAST(_interpqueues_bind), METH_FASTCALL|METH_KEYWORDS, _interpqueues_bind__doc__}, static PyObject * -_interpqueues_bind_impl(PyObject *module, qidarg_converter_data qidarg); +_interpqueues_bind_impl(PyObject *module, int64_t qid); static PyObject * _interpqueues_bind(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) @@ -377,17 +377,17 @@ _interpqueues_bind(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py }; #undef KWTUPLE PyObject *argsbuf[1]; - qidarg_converter_data qidarg = {0}; + int64_t qid; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!args) { goto exit; } - if (!qidarg_converter(args[0], &qidarg)) { + if (!qidarg_converter(args[0], &qid)) { goto exit; } - return_value = _interpqueues_bind_impl(module, qidarg); + return_value = _interpqueues_bind_impl(module, qid); exit: return return_value; @@ -405,7 +405,7 @@ PyDoc_STRVAR(_interpqueues_release__doc__, {"release", _PyCFunction_CAST(_interpqueues_release), METH_FASTCALL|METH_KEYWORDS, _interpqueues_release__doc__}, static PyObject * -_interpqueues_release_impl(PyObject *module, qidarg_converter_data qidarg); +_interpqueues_release_impl(PyObject *module, int64_t qid); static PyObject * _interpqueues_release(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) @@ -439,17 +439,17 @@ _interpqueues_release(PyObject *module, PyObject *const *args, Py_ssize_t nargs, }; #undef KWTUPLE PyObject *argsbuf[1]; - qidarg_converter_data qidarg = {0}; + int64_t qid; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!args) { goto exit; } - if (!qidarg_converter(args[0], &qidarg)) { + if (!qidarg_converter(args[0], &qid)) { goto exit; } - return_value = _interpqueues_release_impl(module, qidarg); + return_value = _interpqueues_release_impl(module, qid); exit: return return_value; @@ -465,8 +465,7 @@ PyDoc_STRVAR(_interpqueues_get_maxsize__doc__, {"get_maxsize", _PyCFunction_CAST(_interpqueues_get_maxsize), METH_FASTCALL|METH_KEYWORDS, _interpqueues_get_maxsize__doc__}, static PyObject * -_interpqueues_get_maxsize_impl(PyObject *module, - qidarg_converter_data qidarg); +_interpqueues_get_maxsize_impl(PyObject *module, int64_t qid); static PyObject * _interpqueues_get_maxsize(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) @@ -500,17 +499,17 @@ _interpqueues_get_maxsize(PyObject *module, PyObject *const *args, Py_ssize_t na }; #undef KWTUPLE PyObject *argsbuf[1]; - qidarg_converter_data qidarg = {0}; + int64_t qid; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!args) { goto exit; } - if (!qidarg_converter(args[0], &qidarg)) { + if (!qidarg_converter(args[0], &qid)) { goto exit; } - return_value = _interpqueues_get_maxsize_impl(module, qidarg); + return_value = _interpqueues_get_maxsize_impl(module, qid); exit: return return_value; @@ -526,8 +525,7 @@ PyDoc_STRVAR(_interpqueues_get_queue_defaults__doc__, {"get_queue_defaults", _PyCFunction_CAST(_interpqueues_get_queue_defaults), METH_FASTCALL|METH_KEYWORDS, _interpqueues_get_queue_defaults__doc__}, static PyObject * -_interpqueues_get_queue_defaults_impl(PyObject *module, - qidarg_converter_data qidarg); +_interpqueues_get_queue_defaults_impl(PyObject *module, int64_t qid); static PyObject * _interpqueues_get_queue_defaults(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) @@ -561,17 +559,17 @@ _interpqueues_get_queue_defaults(PyObject *module, PyObject *const *args, Py_ssi }; #undef KWTUPLE PyObject *argsbuf[1]; - qidarg_converter_data qidarg = {0}; + int64_t qid; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!args) { goto exit; } - if (!qidarg_converter(args[0], &qidarg)) { + if (!qidarg_converter(args[0], &qid)) { goto exit; } - return_value = _interpqueues_get_queue_defaults_impl(module, qidarg); + return_value = _interpqueues_get_queue_defaults_impl(module, qid); exit: return return_value; @@ -587,7 +585,7 @@ PyDoc_STRVAR(_interpqueues_is_full__doc__, {"is_full", _PyCFunction_CAST(_interpqueues_is_full), METH_FASTCALL|METH_KEYWORDS, _interpqueues_is_full__doc__}, static PyObject * -_interpqueues_is_full_impl(PyObject *module, qidarg_converter_data qidarg); +_interpqueues_is_full_impl(PyObject *module, int64_t qid); static PyObject * _interpqueues_is_full(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) @@ -621,17 +619,17 @@ _interpqueues_is_full(PyObject *module, PyObject *const *args, Py_ssize_t nargs, }; #undef KWTUPLE PyObject *argsbuf[1]; - qidarg_converter_data qidarg = {0}; + int64_t qid; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!args) { goto exit; } - if (!qidarg_converter(args[0], &qidarg)) { + if (!qidarg_converter(args[0], &qid)) { goto exit; } - return_value = _interpqueues_is_full_impl(module, qidarg); + return_value = _interpqueues_is_full_impl(module, qid); exit: return return_value; @@ -647,7 +645,7 @@ PyDoc_STRVAR(_interpqueues_get_count__doc__, {"get_count", _PyCFunction_CAST(_interpqueues_get_count), METH_FASTCALL|METH_KEYWORDS, _interpqueues_get_count__doc__}, static PyObject * -_interpqueues_get_count_impl(PyObject *module, qidarg_converter_data qidarg); +_interpqueues_get_count_impl(PyObject *module, int64_t qid); static PyObject * _interpqueues_get_count(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) @@ -681,17 +679,17 @@ _interpqueues_get_count(PyObject *module, PyObject *const *args, Py_ssize_t narg }; #undef KWTUPLE PyObject *argsbuf[1]; - qidarg_converter_data qidarg = {0}; + int64_t qid; args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); if (!args) { goto exit; } - if (!qidarg_converter(args[0], &qidarg)) { + if (!qidarg_converter(args[0], &qid)) { goto exit; } - return_value = _interpqueues_get_count_impl(module, qidarg); + return_value = _interpqueues_get_count_impl(module, qid); exit: return return_value; @@ -761,4 +759,4 @@ _interpqueues__register_heap_types(PyObject *module, PyObject *const *args, Py_s exit: return return_value; } -/*[clinic end generated code: output=bda838d2c69fd3b4 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=290f9d6c610289e2 input=a9049054013a1b77]*/ From 07e8d7ad0ace9a68f219e184529b1d17c61c1678 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 19:08:33 +0100 Subject: [PATCH 14/16] =?UTF-8?q?Fix=20"implicit=20declaration=20of=20func?= =?UTF-8?q?tion=20=E2=80=98qidarg=5Fconverter=E2=80=99"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Modules/_interpqueuesmodule.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Modules/_interpqueuesmodule.c b/Modules/_interpqueuesmodule.c index f6f98d3c877121..d0fbc606aa024b 100644 --- a/Modules/_interpqueuesmodule.c +++ b/Modules/_interpqueuesmodule.c @@ -16,8 +16,6 @@ #undef HAS_FALLBACK #undef REGISTERS_HEAP_TYPES -#include "clinic/_interpqueuesmodule.c.h" - #define MODULE_NAME _interpqueues #define MODULE_NAME_STR Py_STRINGIFY(MODULE_NAME) @@ -29,15 +27,6 @@ module _interpqueues [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=cb1313f77fab132b]*/ -/*[python input] - -class qidarg_converter(CConverter): - type = 'int64_t' - converter = 'qidarg_converter' - -[python start generated code]*/ -/*[python end generated code: output=da39a3ee5e6b4b0d input=c64fbf36771164d6]*/ - #define GLOBAL_MALLOC(TYPE) \ PyMem_RawMalloc(sizeof(TYPE)) #define GLOBAL_FREE(VAR) \ @@ -1482,6 +1471,15 @@ clear_interpreter(void *data) } +/*[python input] + +class qidarg_converter(CConverter): + type = 'int64_t' + converter = 'qidarg_converter' + +[python start generated code]*/ +/*[python end generated code: output=da39a3ee5e6b4b0d input=c64fbf36771164d6]*/ + static int qidarg_converter(PyObject *arg, void *ptr) { @@ -1494,6 +1492,8 @@ qidarg_converter(PyObject *arg, void *ptr) return res; } +#include "clinic/_interpqueuesmodule.c.h" + /*[clinic input] _interpqueues.create From b426a9e6078a19dff134267ad392e186b2aa6131 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 19:10:52 +0100 Subject: [PATCH 15/16] Blurb --- .../next/Library/2025-08-12-19-10-25.gh-issue-137630.n6CkjJ.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2025-08-12-19-10-25.gh-issue-137630.n6CkjJ.rst diff --git a/Misc/NEWS.d/next/Library/2025-08-12-19-10-25.gh-issue-137630.n6CkjJ.rst b/Misc/NEWS.d/next/Library/2025-08-12-19-10-25.gh-issue-137630.n6CkjJ.rst new file mode 100644 index 00000000000000..0c722b8f2c09a6 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-08-12-19-10-25.gh-issue-137630.n6CkjJ.rst @@ -0,0 +1,2 @@ +The :mod:`!_interpqueues` module now uses Argument Clinic to parse arguments. +Patch by Adam Turner. From 000e659e0ea77f78f4b59ddb18ec1df4a62d239c Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 12 Aug 2025 19:11:37 +0100 Subject: [PATCH 16/16] make regen-all --- .../pycore_global_objects_fini_generated.h | 7 +++++ Include/internal/pycore_global_strings.h | 7 +++++ .../internal/pycore_runtime_init_generated.h | 7 +++++ .../internal/pycore_unicodeobject_generated.h | 28 +++++++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/Include/internal/pycore_global_objects_fini_generated.h b/Include/internal/pycore_global_objects_fini_generated.h index d8fefa16faf70f..1a937250189e1e 100644 --- a/Include/internal/pycore_global_objects_fini_generated.h +++ b/Include/internal/pycore_global_objects_fini_generated.h @@ -925,6 +925,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(eager_start)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(effective_ids)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(element_factory)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(emptyerror)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(encode)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(encoding)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(end)); @@ -949,6 +950,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(extra_tokens)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(facility)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(factory)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fallback)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(false)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(family)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fanout)); @@ -980,6 +982,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fromtimestamp)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fromutc)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fset)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(fullerror)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(func)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(future)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(generation)); @@ -1091,6 +1094,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(maxevents)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(maxlen)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(maxmem)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(maxsize)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(maxsplit)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(maxvalue)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(memLevel)); @@ -1185,7 +1189,9 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(protocol)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(ps1)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(ps2)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(qid)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(query)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(queuetype)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(quotetabs)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(raw)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(read)); @@ -1305,6 +1311,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) { _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tzinfo)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(tzname)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(uid)); + _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(unboundop)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(unlink)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(unraisablehook)); _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(updates)); diff --git a/Include/internal/pycore_global_strings.h b/Include/internal/pycore_global_strings.h index b9207f46cd729d..fff1e818dfd6f2 100644 --- a/Include/internal/pycore_global_strings.h +++ b/Include/internal/pycore_global_strings.h @@ -416,6 +416,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(eager_start) STRUCT_FOR_ID(effective_ids) STRUCT_FOR_ID(element_factory) + STRUCT_FOR_ID(emptyerror) STRUCT_FOR_ID(encode) STRUCT_FOR_ID(encoding) STRUCT_FOR_ID(end) @@ -440,6 +441,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(extra_tokens) STRUCT_FOR_ID(facility) STRUCT_FOR_ID(factory) + STRUCT_FOR_ID(fallback) STRUCT_FOR_ID(false) STRUCT_FOR_ID(family) STRUCT_FOR_ID(fanout) @@ -471,6 +473,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(fromtimestamp) STRUCT_FOR_ID(fromutc) STRUCT_FOR_ID(fset) + STRUCT_FOR_ID(fullerror) STRUCT_FOR_ID(func) STRUCT_FOR_ID(future) STRUCT_FOR_ID(generation) @@ -582,6 +585,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(maxevents) STRUCT_FOR_ID(maxlen) STRUCT_FOR_ID(maxmem) + STRUCT_FOR_ID(maxsize) STRUCT_FOR_ID(maxsplit) STRUCT_FOR_ID(maxvalue) STRUCT_FOR_ID(memLevel) @@ -676,7 +680,9 @@ struct _Py_global_strings { STRUCT_FOR_ID(protocol) STRUCT_FOR_ID(ps1) STRUCT_FOR_ID(ps2) + STRUCT_FOR_ID(qid) STRUCT_FOR_ID(query) + STRUCT_FOR_ID(queuetype) STRUCT_FOR_ID(quotetabs) STRUCT_FOR_ID(raw) STRUCT_FOR_ID(read) @@ -796,6 +802,7 @@ struct _Py_global_strings { STRUCT_FOR_ID(tzinfo) STRUCT_FOR_ID(tzname) STRUCT_FOR_ID(uid) + STRUCT_FOR_ID(unboundop) STRUCT_FOR_ID(unlink) STRUCT_FOR_ID(unraisablehook) STRUCT_FOR_ID(updates) diff --git a/Include/internal/pycore_runtime_init_generated.h b/Include/internal/pycore_runtime_init_generated.h index 254b02be1334bd..e42b606248ba1f 100644 --- a/Include/internal/pycore_runtime_init_generated.h +++ b/Include/internal/pycore_runtime_init_generated.h @@ -923,6 +923,7 @@ extern "C" { INIT_ID(eager_start), \ INIT_ID(effective_ids), \ INIT_ID(element_factory), \ + INIT_ID(emptyerror), \ INIT_ID(encode), \ INIT_ID(encoding), \ INIT_ID(end), \ @@ -947,6 +948,7 @@ extern "C" { INIT_ID(extra_tokens), \ INIT_ID(facility), \ INIT_ID(factory), \ + INIT_ID(fallback), \ INIT_ID(false), \ INIT_ID(family), \ INIT_ID(fanout), \ @@ -978,6 +980,7 @@ extern "C" { INIT_ID(fromtimestamp), \ INIT_ID(fromutc), \ INIT_ID(fset), \ + INIT_ID(fullerror), \ INIT_ID(func), \ INIT_ID(future), \ INIT_ID(generation), \ @@ -1089,6 +1092,7 @@ extern "C" { INIT_ID(maxevents), \ INIT_ID(maxlen), \ INIT_ID(maxmem), \ + INIT_ID(maxsize), \ INIT_ID(maxsplit), \ INIT_ID(maxvalue), \ INIT_ID(memLevel), \ @@ -1183,7 +1187,9 @@ extern "C" { INIT_ID(protocol), \ INIT_ID(ps1), \ INIT_ID(ps2), \ + INIT_ID(qid), \ INIT_ID(query), \ + INIT_ID(queuetype), \ INIT_ID(quotetabs), \ INIT_ID(raw), \ INIT_ID(read), \ @@ -1303,6 +1309,7 @@ extern "C" { INIT_ID(tzinfo), \ INIT_ID(tzname), \ INIT_ID(uid), \ + INIT_ID(unboundop), \ INIT_ID(unlink), \ INIT_ID(unraisablehook), \ INIT_ID(updates), \ diff --git a/Include/internal/pycore_unicodeobject_generated.h b/Include/internal/pycore_unicodeobject_generated.h index f1f6bc48fdf1a3..e17aebc2b8ba71 100644 --- a/Include/internal/pycore_unicodeobject_generated.h +++ b/Include/internal/pycore_unicodeobject_generated.h @@ -1452,6 +1452,10 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { _PyUnicode_InternStatic(interp, &string); assert(_PyUnicode_CheckConsistency(string, 1)); assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(emptyerror); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); string = &_Py_ID(encode); _PyUnicode_InternStatic(interp, &string); assert(_PyUnicode_CheckConsistency(string, 1)); @@ -1548,6 +1552,10 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { _PyUnicode_InternStatic(interp, &string); assert(_PyUnicode_CheckConsistency(string, 1)); assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(fallback); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); string = &_Py_ID(false); _PyUnicode_InternStatic(interp, &string); assert(_PyUnicode_CheckConsistency(string, 1)); @@ -1672,6 +1680,10 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { _PyUnicode_InternStatic(interp, &string); assert(_PyUnicode_CheckConsistency(string, 1)); assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(fullerror); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); string = &_Py_ID(func); _PyUnicode_InternStatic(interp, &string); assert(_PyUnicode_CheckConsistency(string, 1)); @@ -2116,6 +2128,10 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { _PyUnicode_InternStatic(interp, &string); assert(_PyUnicode_CheckConsistency(string, 1)); assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(maxsize); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); string = &_Py_ID(maxsplit); _PyUnicode_InternStatic(interp, &string); assert(_PyUnicode_CheckConsistency(string, 1)); @@ -2492,10 +2508,18 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { _PyUnicode_InternStatic(interp, &string); assert(_PyUnicode_CheckConsistency(string, 1)); assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(qid); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); string = &_Py_ID(query); _PyUnicode_InternStatic(interp, &string); assert(_PyUnicode_CheckConsistency(string, 1)); assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(queuetype); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); string = &_Py_ID(quotetabs); _PyUnicode_InternStatic(interp, &string); assert(_PyUnicode_CheckConsistency(string, 1)); @@ -2972,6 +2996,10 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) { _PyUnicode_InternStatic(interp, &string); assert(_PyUnicode_CheckConsistency(string, 1)); assert(PyUnicode_GET_LENGTH(string) != 1); + string = &_Py_ID(unboundop); + _PyUnicode_InternStatic(interp, &string); + assert(_PyUnicode_CheckConsistency(string, 1)); + assert(PyUnicode_GET_LENGTH(string) != 1); string = &_Py_ID(unlink); _PyUnicode_InternStatic(interp, &string); assert(_PyUnicode_CheckConsistency(string, 1));