Skip to content

Commit d51c01a

Browse files
gh-141004: Document PyException_HEAD and PyDescr_COMMON (GH-143896)
1 parent 61ec66a commit d51c01a

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

Doc/c-api/descriptor.rst

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ found in the dictionary of type objects.
1010

1111
.. XXX document these!
1212
13-
.. c:var:: PyTypeObject PyProperty_Type
14-
15-
The type object for the built-in descriptor types.
16-
17-
1813
.. c:function:: PyObject* PyDescr_NewGetSet(PyTypeObject *type, struct PyGetSetDef *getset)
1914
2015
@@ -74,9 +69,26 @@ found in the dictionary of type objects.
7469
.. c:function:: PyObject* PyWrapper_New(PyObject *, PyObject *)
7570
7671
72+
.. c:macro:: PyDescr_COMMON
73+
74+
This is a :term:`soft deprecated` macro including the common fields for a
75+
descriptor object.
76+
77+
This was included in Python's C API by mistake; do not use it in extensions.
78+
For creating custom descriptor objects, create a class implementing the
79+
descriptor protocol (:c:member:`~PyTypeObject.tp_descr_get` and
80+
:c:member:`~PyTypeObject.tp_descr_set`).
81+
82+
7783
Built-in descriptors
7884
^^^^^^^^^^^^^^^^^^^^
7985
86+
.. c:var:: PyTypeObject PyProperty_Type
87+
88+
The type object for property objects. This is the same object as
89+
:class:`property` in the Python layer.
90+
91+
8092
.. c:var:: PyTypeObject PySuper_Type
8193
8294
The type object for super objects. This is the same object as

Doc/c-api/exceptions.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,17 @@ Exception Classes
793793
Return :c:member:`~PyTypeObject.tp_name` of the exception class *ob*.
794794
795795
796+
.. c:macro:: PyException_HEAD
797+
798+
This is a :term:`soft deprecated` macro including the base fields for an
799+
exception object.
800+
801+
This was included in Python's C API by mistake and is not designed for use
802+
in extensions. For creating custom exception objects, use
803+
:c:func:`PyErr_NewException` or otherwise create a class inheriting from
804+
:c:data:`PyExc_BaseException`.
805+
806+
796807
Exception Objects
797808
=================
798809

Tools/check-c-api-docs/ignored_c_api.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ PyCF_MASK
6666
PyCF_MASK_OBSOLETE
6767
PyCF_SOURCE_IS_UTF8
6868
# cpython/descrobject.h
69-
PyDescr_COMMON
7069
PyDescr_NAME
7170
PyDescr_TYPE
7271
PyWrapperFlag_KEYWORDS
@@ -76,8 +75,6 @@ Py_UniversalNewlineFgets
7675
PyUnstable_CopyPerfMapFile
7776
PyUnstable_PerfTrampoline_CompileCode
7877
PyUnstable_PerfTrampoline_SetPersistAfterFork
79-
# cpython/pyerrors.h
80-
PyException_HEAD
8178
# cpython/pyframe.h
8279
PyUnstable_EXECUTABLE_KINDS
8380
PyUnstable_EXECUTABLE_KIND_BUILTIN_FUNCTION
@@ -121,4 +118,4 @@ PY_MONITORING_EVENT_BRANCH
121118
PY_DEF_EVENT
122119
PY_FOREACH_DICT_EVENT
123120
# cpython/pystats.h
124-
PYSTATS_MAX_UOP_ID
121+
PYSTATS_MAX_UOP_ID

0 commit comments

Comments
 (0)