diff options
author | Oleg Iarygin <oleg@arhadthedev.net> | 2022-04-19 02:56:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-19 02:56:53 (GMT) |
commit | 7fbc7f61280d301c0ac88b65ee8747fcf19f01f8 (patch) | |
tree | f28c4d9e1ce47eddd7880bd623523b6b2551790a /Objects/clinic | |
parent | 014eb7fd0242963ac475abb3c1fb9be0714b203f (diff) | |
download | cpython-7fbc7f61280d301c0ac88b65ee8747fcf19f01f8.zip cpython-7fbc7f61280d301c0ac88b65ee8747fcf19f01f8.tar.gz cpython-7fbc7f61280d301c0ac88b65ee8747fcf19f01f8.tar.bz2 |
gh-91098: Use Argument Clinic for Object/classobject.c to fix docstrings (#31711)
Closes GH-91098.
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Diffstat (limited to 'Objects/clinic')
-rw-r--r-- | Objects/clinic/classobject.c.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/Objects/clinic/classobject.c.h b/Objects/clinic/classobject.c.h new file mode 100644 index 0000000..a4f1900 --- /dev/null +++ b/Objects/clinic/classobject.c.h @@ -0,0 +1,83 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(method___reduce____doc__, +"__reduce__($self, /)\n" +"--\n" +"\n"); + +#define METHOD___REDUCE___METHODDEF \ + {"__reduce__", (PyCFunction)method___reduce__, METH_NOARGS, method___reduce____doc__}, + +static PyObject * +method___reduce___impl(PyMethodObject *self); + +static PyObject * +method___reduce__(PyMethodObject *self, PyObject *Py_UNUSED(ignored)) +{ + return method___reduce___impl(self); +} + +PyDoc_STRVAR(method_new__doc__, +"method(function, instance, /)\n" +"--\n" +"\n" +"Create a bound instance method object."); + +static PyObject * +method_new_impl(PyTypeObject *type, PyObject *function, PyObject *instance); + +static PyObject * +method_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *function; + PyObject *instance; + + if ((type == &PyMethod_Type || + type->tp_init == PyMethod_Type.tp_init) && + !_PyArg_NoKeywords("method", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("method", PyTuple_GET_SIZE(args), 2, 2)) { + goto exit; + } + function = PyTuple_GET_ITEM(args, 0); + instance = PyTuple_GET_ITEM(args, 1); + return_value = method_new_impl(type, function, instance); + +exit: + return return_value; +} + +PyDoc_STRVAR(instancemethod_new__doc__, +"instancemethod(function, /)\n" +"--\n" +"\n" +"Bind a function to a class."); + +static PyObject * +instancemethod_new_impl(PyTypeObject *type, PyObject *function); + +static PyObject * +instancemethod_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *function; + + if ((type == &PyInstanceMethod_Type || + type->tp_init == PyInstanceMethod_Type.tp_init) && + !_PyArg_NoKeywords("instancemethod", kwargs)) { + goto exit; + } + if (!_PyArg_CheckPositional("instancemethod", PyTuple_GET_SIZE(args), 1, 1)) { + goto exit; + } + function = PyTuple_GET_ITEM(args, 0); + return_value = instancemethod_new_impl(type, function); + +exit: + return return_value; +} +/*[clinic end generated code: output=a230fe125f664416 input=a9049054013a1b77]*/ |