summaryrefslogtreecommitdiffstats
path: root/Modules/clinic
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-11-29 10:07:37 (GMT)
committerGitHub <noreply@github.com>2022-11-29 10:07:37 (GMT)
commit4cfc1b8568bd8bf0d44fadc42ec86696d0561d33 (patch)
tree502dea89ade82a73a02f6c23eb749644a4aba69e /Modules/clinic
parentdeaa8dee48beeae9928a418736da0608f2f18361 (diff)
downloadcpython-4cfc1b8568bd8bf0d44fadc42ec86696d0561d33.zip
cpython-4cfc1b8568bd8bf0d44fadc42ec86696d0561d33.tar.gz
cpython-4cfc1b8568bd8bf0d44fadc42ec86696d0561d33.tar.bz2
GH-91375: Port `_asyncio` static types to heap types and module state (#99122)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Diffstat (limited to 'Modules/clinic')
-rw-r--r--Modules/clinic/_asynciomodule.c.h175
1 files changed, 145 insertions, 30 deletions
diff --git a/Modules/clinic/_asynciomodule.c.h b/Modules/clinic/_asynciomodule.c.h
index ddec54c..11db478 100644
--- a/Modules/clinic/_asynciomodule.c.h
+++ b/Modules/clinic/_asynciomodule.c.h
@@ -112,15 +112,19 @@ PyDoc_STRVAR(_asyncio_Future_exception__doc__,
"InvalidStateError.");
#define _ASYNCIO_FUTURE_EXCEPTION_METHODDEF \
- {"exception", (PyCFunction)_asyncio_Future_exception, METH_NOARGS, _asyncio_Future_exception__doc__},
+ {"exception", _PyCFunction_CAST(_asyncio_Future_exception), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_exception__doc__},
static PyObject *
-_asyncio_Future_exception_impl(FutureObj *self);
+_asyncio_Future_exception_impl(FutureObj *self, PyTypeObject *cls);
static PyObject *
-_asyncio_Future_exception(FutureObj *self, PyObject *Py_UNUSED(ignored))
+_asyncio_Future_exception(FutureObj *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- return _asyncio_Future_exception_impl(self);
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "exception() takes no arguments");
+ return NULL;
+ }
+ return _asyncio_Future_exception_impl(self, cls);
}
PyDoc_STRVAR(_asyncio_Future_set_result__doc__,
@@ -133,7 +137,42 @@ PyDoc_STRVAR(_asyncio_Future_set_result__doc__,
"InvalidStateError.");
#define _ASYNCIO_FUTURE_SET_RESULT_METHODDEF \
- {"set_result", (PyCFunction)_asyncio_Future_set_result, METH_O, _asyncio_Future_set_result__doc__},
+ {"set_result", _PyCFunction_CAST(_asyncio_Future_set_result), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_set_result__doc__},
+
+static PyObject *
+_asyncio_Future_set_result_impl(FutureObj *self, PyTypeObject *cls,
+ PyObject *result);
+
+static PyObject *
+_asyncio_Future_set_result(FutureObj *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
+ # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
+ #else
+ # define KWTUPLE NULL
+ #endif
+
+ static const char * const _keywords[] = {"", NULL};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "set_result",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
+ PyObject *argsbuf[1];
+ PyObject *result;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ result = args[0];
+ return_value = _asyncio_Future_set_result_impl(self, cls, result);
+
+exit:
+ return return_value;
+}
PyDoc_STRVAR(_asyncio_Future_set_exception__doc__,
"set_exception($self, exception, /)\n"
@@ -145,7 +184,42 @@ PyDoc_STRVAR(_asyncio_Future_set_exception__doc__,
"InvalidStateError.");
#define _ASYNCIO_FUTURE_SET_EXCEPTION_METHODDEF \
- {"set_exception", (PyCFunction)_asyncio_Future_set_exception, METH_O, _asyncio_Future_set_exception__doc__},
+ {"set_exception", _PyCFunction_CAST(_asyncio_Future_set_exception), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_set_exception__doc__},
+
+static PyObject *
+_asyncio_Future_set_exception_impl(FutureObj *self, PyTypeObject *cls,
+ PyObject *exception);
+
+static PyObject *
+_asyncio_Future_set_exception(FutureObj *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
+ # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
+ #else
+ # define KWTUPLE NULL
+ #endif
+
+ static const char * const _keywords[] = {"", NULL};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "set_exception",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
+ PyObject *argsbuf[1];
+ PyObject *exception;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ exception = args[0];
+ return_value = _asyncio_Future_set_exception_impl(self, cls, exception);
+
+exit:
+ return return_value;
+}
PyDoc_STRVAR(_asyncio_Future_add_done_callback__doc__,
"add_done_callback($self, fn, /, *, context=<unrepresentable>)\n"
@@ -158,14 +232,14 @@ PyDoc_STRVAR(_asyncio_Future_add_done_callback__doc__,
"scheduled with call_soon.");
#define _ASYNCIO_FUTURE_ADD_DONE_CALLBACK_METHODDEF \
- {"add_done_callback", _PyCFunction_CAST(_asyncio_Future_add_done_callback), METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_add_done_callback__doc__},
+ {"add_done_callback", _PyCFunction_CAST(_asyncio_Future_add_done_callback), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_add_done_callback__doc__},
static PyObject *
-_asyncio_Future_add_done_callback_impl(FutureObj *self, PyObject *fn,
- PyObject *context);
+_asyncio_Future_add_done_callback_impl(FutureObj *self, PyTypeObject *cls,
+ PyObject *fn, PyObject *context);
static PyObject *
-_asyncio_Future_add_done_callback(FutureObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+_asyncio_Future_add_done_callback(FutureObj *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
@@ -208,7 +282,7 @@ _asyncio_Future_add_done_callback(FutureObj *self, PyObject *const *args, Py_ssi
}
context = args[1];
skip_optional_kwonly:
- return_value = _asyncio_Future_add_done_callback_impl(self, fn, context);
+ return_value = _asyncio_Future_add_done_callback_impl(self, cls, fn, context);
exit:
return return_value;
@@ -223,7 +297,42 @@ PyDoc_STRVAR(_asyncio_Future_remove_done_callback__doc__,
"Returns the number of callbacks removed.");
#define _ASYNCIO_FUTURE_REMOVE_DONE_CALLBACK_METHODDEF \
- {"remove_done_callback", (PyCFunction)_asyncio_Future_remove_done_callback, METH_O, _asyncio_Future_remove_done_callback__doc__},
+ {"remove_done_callback", _PyCFunction_CAST(_asyncio_Future_remove_done_callback), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_remove_done_callback__doc__},
+
+static PyObject *
+_asyncio_Future_remove_done_callback_impl(FutureObj *self, PyTypeObject *cls,
+ PyObject *fn);
+
+static PyObject *
+_asyncio_Future_remove_done_callback(FutureObj *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
+ # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
+ #else
+ # define KWTUPLE NULL
+ #endif
+
+ static const char * const _keywords[] = {"", NULL};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "remove_done_callback",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
+ PyObject *argsbuf[1];
+ PyObject *fn;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ fn = args[0];
+ return_value = _asyncio_Future_remove_done_callback_impl(self, cls, fn);
+
+exit:
+ return return_value;
+}
PyDoc_STRVAR(_asyncio_Future_cancel__doc__,
"cancel($self, /, msg=None)\n"
@@ -236,13 +345,14 @@ PyDoc_STRVAR(_asyncio_Future_cancel__doc__,
"return True.");
#define _ASYNCIO_FUTURE_CANCEL_METHODDEF \
- {"cancel", _PyCFunction_CAST(_asyncio_Future_cancel), METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_cancel__doc__},
+ {"cancel", _PyCFunction_CAST(_asyncio_Future_cancel), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_cancel__doc__},
static PyObject *
-_asyncio_Future_cancel_impl(FutureObj *self, PyObject *msg);
+_asyncio_Future_cancel_impl(FutureObj *self, PyTypeObject *cls,
+ PyObject *msg);
static PyObject *
-_asyncio_Future_cancel(FutureObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+_asyncio_Future_cancel(FutureObj *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
@@ -283,7 +393,7 @@ _asyncio_Future_cancel(FutureObj *self, PyObject *const *args, Py_ssize_t nargs,
}
msg = args[0];
skip_optional_pos:
- return_value = _asyncio_Future_cancel_impl(self, msg);
+ return_value = _asyncio_Future_cancel_impl(self, cls, msg);
exit:
return return_value;
@@ -335,15 +445,19 @@ PyDoc_STRVAR(_asyncio_Future_get_loop__doc__,
"Return the event loop the Future is bound to.");
#define _ASYNCIO_FUTURE_GET_LOOP_METHODDEF \
- {"get_loop", (PyCFunction)_asyncio_Future_get_loop, METH_NOARGS, _asyncio_Future_get_loop__doc__},
+ {"get_loop", _PyCFunction_CAST(_asyncio_Future_get_loop), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Future_get_loop__doc__},
static PyObject *
-_asyncio_Future_get_loop_impl(FutureObj *self);
+_asyncio_Future_get_loop_impl(FutureObj *self, PyTypeObject *cls);
static PyObject *
-_asyncio_Future_get_loop(FutureObj *self, PyObject *Py_UNUSED(ignored))
+_asyncio_Future_get_loop(FutureObj *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- return _asyncio_Future_get_loop_impl(self);
+ if (nargs) {
+ PyErr_SetString(PyExc_TypeError, "get_loop() takes no arguments");
+ return NULL;
+ }
+ return _asyncio_Future_get_loop_impl(self, cls);
}
PyDoc_STRVAR(_asyncio_Future__make_cancelled_error__doc__,
@@ -612,13 +726,14 @@ PyDoc_STRVAR(_asyncio_Task_get_stack__doc__,
"returned for a suspended coroutine.");
#define _ASYNCIO_TASK_GET_STACK_METHODDEF \
- {"get_stack", _PyCFunction_CAST(_asyncio_Task_get_stack), METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_get_stack__doc__},
+ {"get_stack", _PyCFunction_CAST(_asyncio_Task_get_stack), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_get_stack__doc__},
static PyObject *
-_asyncio_Task_get_stack_impl(TaskObj *self, PyObject *limit);
+_asyncio_Task_get_stack_impl(TaskObj *self, PyTypeObject *cls,
+ PyObject *limit);
static PyObject *
-_asyncio_Task_get_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+_asyncio_Task_get_stack(TaskObj *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
@@ -659,7 +774,7 @@ _asyncio_Task_get_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs,
}
limit = args[0];
skip_optional_kwonly:
- return_value = _asyncio_Task_get_stack_impl(self, limit);
+ return_value = _asyncio_Task_get_stack_impl(self, cls, limit);
exit:
return return_value;
@@ -678,14 +793,14 @@ PyDoc_STRVAR(_asyncio_Task_print_stack__doc__,
"to sys.stderr.");
#define _ASYNCIO_TASK_PRINT_STACK_METHODDEF \
- {"print_stack", _PyCFunction_CAST(_asyncio_Task_print_stack), METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_print_stack__doc__},
+ {"print_stack", _PyCFunction_CAST(_asyncio_Task_print_stack), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _asyncio_Task_print_stack__doc__},
static PyObject *
-_asyncio_Task_print_stack_impl(TaskObj *self, PyObject *limit,
- PyObject *file);
+_asyncio_Task_print_stack_impl(TaskObj *self, PyTypeObject *cls,
+ PyObject *limit, PyObject *file);
static PyObject *
-_asyncio_Task_print_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+_asyncio_Task_print_stack(TaskObj *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
@@ -733,7 +848,7 @@ _asyncio_Task_print_stack(TaskObj *self, PyObject *const *args, Py_ssize_t nargs
}
file = args[1];
skip_optional_kwonly:
- return_value = _asyncio_Task_print_stack_impl(self, limit, file);
+ return_value = _asyncio_Task_print_stack_impl(self, cls, limit, file);
exit:
return return_value;
@@ -1189,4 +1304,4 @@ _asyncio__leave_task(PyObject *module, PyObject *const *args, Py_ssize_t nargs,
exit:
return return_value;
}
-/*[clinic end generated code: output=f117b2246eaf7a55 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=550bc6603df89ed9 input=a9049054013a1b77]*/