@@ -117,6 +117,13 @@ Type Objects
117117 If no module is associated with the given type, sets :py:class: `TypeError `
118118 and returns ``NULL ``.
119119
120+ This function is usually used to get the module in which a method is defined.
121+ Note that in such a method, ``PyType_GetModule(Py_TYPE(self)) ``
122+ may not return the intended result.
123+ ``Py_TYPE(self) `` may be a *subclass * of the intended class, and subclasses
124+ are not necessarily defined in the same module as their superclass.
125+ See :c:type: `PyCMethod ` to get the class that defines the method.
126+
120127 .. versionadded :: 3.9
121128
122129.. c :function :: void * PyType_GetModuleState (PyTypeObject *type)
@@ -151,9 +158,12 @@ The following functions and structs are used to create
151158 If *bases* is ``NULL``, the *Py_tp_base* slot is used instead.
152159 If that also is ``NULL``, the new type derives from :class:`object`.
153160
154- The *module* must be a module object or ``NULL``.
161+ The *module* argument can be used to record the module in which the new
162+ class is defined. It must be a module object or ``NULL``.
155163 If not ``NULL``, the module is associated with the new type and can later be
156164 retreived with :c:func:`PyType_GetModule`.
165+ The associated module is not inherited by subclasses; it must be specified
166+ for each class individually.
157167
158168 This function calls :c:func: `PyType_Ready ` on the new type.
159169
@@ -215,7 +225,8 @@ The following functions and structs are used to create
215225 * ``Py_nb_add `` to set :c:member: `PyNumberMethods.nb_add `
216226 * ``Py_sq_length `` to set :c:member: `PySequenceMethods.sq_length `
217227
218- The following fields cannot be set using :c:type: `PyType_Spec ` and :c:type: `PyType_Slot `:
228+ The following fields cannot be set at all using :c:type: `PyType_Spec ` and
229+ :c:type: `PyType_Slot `:
219230
220231 * :c:member: `~PyTypeObject.tp_dict `
221232 * :c:member: `~PyTypeObject.tp_mro `
@@ -229,13 +240,21 @@ The following functions and structs are used to create
229240 (see :ref: `PyMemberDef <pymemberdef-offsets >`)
230241 * :c:member:`~PyTypeObject.tp_vectorcall_offset`
231242 (see :ref: `PyMemberDef <pymemberdef-offsets >`)
243+
244+ The following fields cannot be set using :c:type:`PyType_Spec` and
245+ :c:type:`PyType_Slot` under the limited API:
246+
232247 * :c:member:`~PyBufferProcs.bf_getbuffer`
233248 * :c:member:`~PyBufferProcs.bf_releasebuffer`
234249
235250 Setting :c:data:`Py_tp_bases` may be problematic on some platforms.
236251 To avoid issues, use the *bases* argument of
237252 :py:func:`PyType_FromSpecWithBases` instead.
238253
254+ .. versionchanged:: 3.9
255+
256+ Slots in :c:type:`PyBufferProcs` in may be set in the unlimited API.
257+
239258 .. c:member:: void *PyType_Slot.pfunc
240259
241260 The desired value of the slot. In most cases, this is a pointer
0 commit comments