bpo-40024: Add PyModule_AddType() helper function (GH-19088)
diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst
index 8d1a0fb..8cf26fb 100644
--- a/Doc/c-api/module.rst
+++ b/Doc/c-api/module.rst
@@ -441,7 +441,7 @@
Add an object to *module* as *name*. This is a convenience function which can
be used from the module's initialization function. This steals a reference to
- *value* on success. Return ``-1`` on error, ``0`` on success.
+ *value* on success. Return ``-1`` on error, ``0`` on success.
.. note::
@@ -484,6 +484,16 @@
Add a string constant to *module*.
+.. c:function:: int PyModule_AddType(PyObject *module, PyTypeObject *type)
+
+ Add a type object to *module*.
+ The type object is finalized by calling internally :c:func:`PyType_Ready`.
+ The name of the type object is taken from the last component of
+ :c:member:`~PyTypeObject.tp_name` after dot.
+ Return ``-1`` on error, ``0`` on success.
+
+ .. versionadded:: 3.9
+
Module lookup
^^^^^^^^^^^^^
diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst
index 5c84ca1..9f9e895 100644
--- a/Doc/whatsnew/3.9.rst
+++ b/Doc/whatsnew/3.9.rst
@@ -538,6 +538,9 @@
by the internal C API. Remove also ``PyThreadFrameGetter`` type.
(Contributed by Victor Stinner in :issue:`39946`.)
+* The :c:func:`PyModule_AddType` function is added to help adding a type to a module.
+ (Contributed by Dong-hee Na in :issue:`40024`.)
+
Deprecated
==========