@@ -193,11 +193,12 @@ The following functions and structs are used to create
193193.. c:function:: PyObject* PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases)
194194
195195 Create and return a :ref: `heap type <heap-types >` from the *spec *
196- (:const: `Py_TPFLAGS_HEAPTYPE `).
196+ (see :const: `Py_TPFLAGS_HEAPTYPE `).
197197
198198 The metaclass *metaclass* is used to construct the resulting type object.
199- When *metaclass* is ``NULL``, the default :c:type:`PyType_Type` is used
200- instead. Note that metaclasses that override
199+ When *metaclass* is ``NULL``, the metaclass is derived from *bases*
200+ (or *Py_tp_base[s] * slots if *bases * is ``NULL ``, see below).
201+ Note that metaclasses that override
201202 :c:member:`~PyTypeObject.tp_new` are not supported.
202203
203204 The *bases* argument can be used to specify base classes; it can either
@@ -215,6 +216,19 @@ The following functions and structs are used to create
215216
216217 This function calls :c:func: `PyType_Ready ` on the new type.
217218
219+ Note that this function does *not * fully match the behavior of
220+ calling :py:class: `type() <type> ` or using the :keyword: `class ` statement.
221+ With user-provided base types or metaclasses, prefer
222+ :ref: `calling <capi-call >` :py:class: `type ` (or the metaclass)
223+ over ``PyType_From*`` functions.
224+ Specifically:
225+
226+ * :py:meth:`~object.__new__` is not called on the new class
227+ (and it must be set to ``type.__new__ ``).
228+ * :py:meth:`~object.__init__` is not called on the new class.
229+ * :py:meth:`~object.__init_subclass__` is not called on any bases.
230+ * :py:meth:`~object.__set_name__` is not called on new descriptors.
231+
218232 .. versionadded:: 3.12
219233
220234.. c:function:: PyObject* PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
@@ -228,17 +242,33 @@ The following functions and structs are used to create
228242 The function now accepts a single class as the *bases * argument and
229243 ``NULL `` as the ``tp_doc `` slot.
230244
245+ .. versionchanged :: 3.12
246+
247+ The function now finds and uses a metaclass corresponding to the provided
248+ base classes. Previously, only :class: `type ` instances were returned.
249+
231250
232251.. c :function :: PyObject* PyType_FromSpecWithBases (PyType_Spec *spec, PyObject *bases)
233252
234253 Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, bases) ``.
235254
236255 .. versionadded :: 3.3
237256
257+ .. versionchanged :: 3.12
258+
259+ The function now finds and uses a metaclass corresponding to the provided
260+ base classes. Previously, only :class: `type ` instances were returned.
261+
238262.. c :function :: PyObject* PyType_FromSpec (PyType_Spec *spec)
239263
240264 Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, NULL) ``.
241265
266+ .. versionchanged :: 3.12
267+
268+ The function now finds and uses a metaclass corresponding to the
269+ base classes provided in *Py_tp_base[s] * slots.
270+ Previously, only :class: `type ` instances were returned.
271+
242272.. c :type :: PyType_Spec
243273
244274 Structure defining a type's behavior.
@@ -266,6 +296,8 @@ The following functions and structs are used to create
266296 Array of :c:type: `PyType_Slot ` structures.
267297 Terminated by the special slot value ``{0, NULL} ``.
268298
299+ Each slot ID should be specified at most once.
300+
269301.. c :type :: PyType_Slot
270302
271303 Structure defining optional functionality of a type, containing a slot ID
0 commit comments