Skip to content

Commit 7fcc6e4

Browse files
committed
Remove outdated PyUnstable_TPFLAGS_CAN_IMMORTALIZE documentation.
1 parent 31c2549 commit 7fcc6e4

2 files changed

Lines changed: 18 additions & 21 deletions

File tree

Doc/c-api/object.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,24 @@ Object Protocol
619619
:term:`reference count` modifications, via :c:macro:`Py_INCREF` or :c:macro:`Py_DECREF`, with
620620
the cost of being less memory efficient.
621621
622-
See (PEP number) for more information.
622+
In order to be made immortal, an object must follow the "immortalization
623+
contract". This contract is based on best practices in Python's C API, and
624+
it's very unlikely that a type doesn't follow it.
625+
626+
* The object must be allocated under either the "object" or "memory" allocator
627+
domains. See :ref:`Allocator Domains <allocator-domains>` for more information.
628+
Default values of :c:member:`~PyTypeObject.tp_alloc` always use the object
629+
allocator.
630+
* All :term:`strong references <strong reference>` released in the object's
631+
:c:member:`~PyTypeObject.tp_dealloc` slot must also be traversed by the
632+
object's :c:member:`~PyTypeObject.tp_traverse` slot, if the type can
633+
contain circular references. This is generally true for any garbage
634+
collected type.
635+
* All finalization must be done in :c:member:`~PyTypeObject.tp_finalize`
636+
alongside :c:func:`PyObject_CallFinalizerFromDealloc`. This does *not*
637+
include finalizers triggered by :c:macro:`Py_DECREF`; as long as they also
638+
follow this contract, it is safe to release references in a destructor.
639+
This is almost always true as of :pep:`442`.
623640
624641
.. warning::
625642

Doc/c-api/typeobj.rst

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,26 +1458,6 @@ and :c:data:`PyType_Type` effectively act as defaults.)
14581458
This flag is present in header files, but is not be used.
14591459
It will be removed in a future version of CPython
14601460

1461-
.. c:macro:: PyUnstable_TPFLAGS_CAN_IMMORTALIZE
1462-
1463-
This bit indicates that instances of the class may be made :term:`immortal`
1464-
via :c:func:`PyUnstable_Immortalize` or :func:`sys._immortalize`.
1465-
1466-
In order for instances to safely be made immortal, the class must follow a set of rules:
1467-
1468-
* It must use either the "object" or "memory" allocator domains.
1469-
See :ref:`Allocator Domains <allocator-domains>` for more information.
1470-
* It must not rely on specific :term:`reference count` values in methods
1471-
(via :c:macro:`Py_REFCNT`).
1472-
* All :term:`strong references <strong reference>` released in the object's
1473-
:c:member:`~PyTypeObject.tp_dealloc` slot must also be traversed by the
1474-
object's :c:member:`~PyTypeObject.tp_traverse` slot, if the type can
1475-
contain circular references.
1476-
* All finalization must be done in :c:member:`~PyTypeObject.tp_finalize`
1477-
alongside :c:func:`!PyObject_CallFinalizerFromDealloc`. This does *not*
1478-
include finalizers triggered by :c:macro:`Py_DECREF`; as long as they also
1479-
follow this contract, it is safe to release references in a destructor.
1480-
14811461

14821462
.. c:member:: const char* PyTypeObject.tp_doc
14831463

0 commit comments

Comments
 (0)