mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-111178: fix incorrect function signatures in docs (#132395)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
This commit is contained in:
parent
3e1a47bdb4
commit
9ded6f0830
3 changed files with 59 additions and 41 deletions
|
@ -703,10 +703,13 @@ and :c:data:`PyType_Type` effectively act as defaults.)
|
|||
|
||||
.. code-block:: c
|
||||
|
||||
static void foo_dealloc(foo_object *self) {
|
||||
static void
|
||||
foo_dealloc(PyObject *op)
|
||||
{
|
||||
foo_object *self = (foo_object *) op;
|
||||
PyObject_GC_UnTrack(self);
|
||||
Py_CLEAR(self->ref);
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
Py_TYPE(self)->tp_free(self);
|
||||
}
|
||||
|
||||
Finally, if the type is heap allocated (:c:macro:`Py_TPFLAGS_HEAPTYPE`), the
|
||||
|
@ -717,10 +720,12 @@ and :c:data:`PyType_Type` effectively act as defaults.)
|
|||
|
||||
.. code-block:: c
|
||||
|
||||
static void foo_dealloc(foo_object *self) {
|
||||
PyTypeObject *tp = Py_TYPE(self);
|
||||
static void
|
||||
foo_dealloc(PyObject *op)
|
||||
{
|
||||
PyTypeObject *tp = Py_TYPE(op);
|
||||
// free references and buffers here
|
||||
tp->tp_free(self);
|
||||
tp->tp_free(op);
|
||||
Py_DECREF(tp);
|
||||
}
|
||||
|
||||
|
@ -1416,8 +1421,9 @@ and :c:data:`PyType_Type` effectively act as defaults.)
|
|||
:mod:`!_thread` extension module::
|
||||
|
||||
static int
|
||||
local_traverse(localobject *self, visitproc visit, void *arg)
|
||||
local_traverse(PyObject *op, visitproc visit, void *arg)
|
||||
{
|
||||
localobject *self = (localobject *) op;
|
||||
Py_VISIT(self->args);
|
||||
Py_VISIT(self->kw);
|
||||
Py_VISIT(self->dict);
|
||||
|
@ -1511,8 +1517,9 @@ and :c:data:`PyType_Type` effectively act as defaults.)
|
|||
members to ``NULL``, as in the following example::
|
||||
|
||||
static int
|
||||
local_clear(localobject *self)
|
||||
local_clear(PyObject *op)
|
||||
{
|
||||
localobject *self = (localobject *) op;
|
||||
Py_CLEAR(self->key);
|
||||
Py_CLEAR(self->args);
|
||||
Py_CLEAR(self->kw);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue