@@ -195,12 +195,14 @@ Type Objects
195195 before initialization) and should be paired with :c:func:`PyObject_Free` in
196196 :c:member:`~PyTypeObject.tp_free`.
197197
198+
198199.. c:function:: PyObject* PyType_GenericNew(PyTypeObject *type, PyObject *args, PyObject *kwds)
199200
200201 Generic handler for the :c:member: `~PyTypeObject.tp_new ` slot of a type
201202 object. Creates a new instance using the type's
202203 :c:member: `~PyTypeObject.tp_alloc ` slot and returns the resulting object.
203204
205+
204206.. c :function :: int PyType_Ready (PyTypeObject *type)
205207
206208 Finalize a type object. This should be called on all type objects to finish
@@ -217,13 +219,15 @@ Type Objects
217219 GC protocol itself by at least implementing the
218220 :c:member: `~PyTypeObject.tp_traverse ` handle.
219221
222+
220223.. c :function :: PyObject* PyType_GetName (PyTypeObject *type)
221224
222225 Return the type's name. Equivalent to getting the type's
223226 :attr: `~type.__name__ ` attribute.
224227
225228 .. versionadded :: 3.11
226229
230+
227231.. c :function :: PyObject* PyType_GetQualName (PyTypeObject *type)
228232
229233 Return the type's qualified name. Equivalent to getting the
@@ -239,13 +243,15 @@ Type Objects
239243
240244 .. versionadded :: 3.13
241245
246+
242247.. c :function :: PyObject* PyType_GetModuleName (PyTypeObject *type)
243248
244249 Return the type's module name. Equivalent to getting the
245250 :attr: `type.__module__ ` attribute.
246251
247252 .. versionadded :: 3.13
248253
254+
249255.. c :function :: void * PyType_GetSlot (PyTypeObject *type, int slot)
250256
251257 Return the function pointer stored in the given slot. If the
@@ -262,6 +268,7 @@ Type Objects
262268 :c:func: `PyType_GetSlot ` can now accept all types.
263269 Previously, it was limited to :ref: `heap types <heap-types >`.
264270
271+
265272.. c :function :: PyObject* PyType_GetModule (PyTypeObject *type)
266273
267274 Return the module object associated with the given type when the type was
@@ -281,6 +288,7 @@ Type Objects
281288
282289 .. versionadded :: 3.9
283290
291+
284292.. c :function :: void * PyType_GetModuleState (PyTypeObject *type)
285293
286294 Return the state of the module object associated with the given type.
@@ -295,6 +303,7 @@ Type Objects
295303
296304 .. versionadded :: 3.9
297305
306+
298307.. c :function :: PyObject* PyType_GetModuleByToken (PyTypeObject *type, const void *token)
299308
300309 Find the first superclass whose module has the given *token *, and
@@ -312,6 +321,7 @@ Type Objects
312321
313322 .. versionadded:: next
314323
324+
315325.. c:function:: PyObject* PyType_GetModuleByDef(PyTypeObject *type, struct PyModuleDef *def)
316326
317327 Find the first superclass whose module was created from the given
@@ -330,6 +340,7 @@ Type Objects
330340
331341 .. versionadded :: 3.11
332342
343+
333344.. c :function :: int PyType_GetBaseByToken (PyTypeObject *type, void *token, PyTypeObject **result)
334345
335346 Find the first superclass in *type *'s :term: `method resolution order ` whose
@@ -348,6 +359,7 @@ Type Objects
348359
349360 .. versionadded :: 3.14
350361
362+
351363.. c :function :: int PyUnstable_Type_AssignVersionTag (PyTypeObject *type)
352364
353365 Attempt to assign a version tag to the given type.
@@ -358,6 +370,16 @@ Type Objects
358370 .. versionadded :: 3.12
359371
360372
373+ .. c :function :: int PyType_SUPPORTS_WEAKREFS (PyTypeObject *type)
374+
375+ Return true if instances of *type * support creating weak references, false
376+ otherwise. This function always succeeds. *type * must not be ``NULL ``.
377+
378+ .. seealso ::
379+ * :ref: `weakrefobjects `
380+ * :py:mod: `weakref `
381+
382+
361383Creating Heap-Allocated Types
362384.............................
363385
@@ -406,6 +428,7 @@ The following functions and structs are used to create
406428
407429 .. versionadded:: 3.12
408430
431+
409432.. c:function:: PyObject* PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
410433
411434 Equivalent to ``PyType_FromMetaclass(NULL, module, spec, bases) ``.
@@ -432,6 +455,7 @@ The following functions and structs are used to create
432455 Creating classes whose metaclass overrides
433456 :c:member: `~PyTypeObject.tp_new ` is no longer allowed.
434457
458+
435459.. c :function :: PyObject* PyType_FromSpecWithBases (PyType_Spec *spec, PyObject *bases)
436460
437461 Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, bases) ``.
@@ -453,6 +477,7 @@ The following functions and structs are used to create
453477 Creating classes whose metaclass overrides
454478 :c:member: `~PyTypeObject.tp_new ` is no longer allowed.
455479
480+
456481.. c :function :: PyObject* PyType_FromSpec (PyType_Spec *spec)
457482
458483 Equivalent to ``PyType_FromMetaclass(NULL, NULL, spec, NULL) ``.
@@ -473,6 +498,7 @@ The following functions and structs are used to create
473498 Creating classes whose metaclass overrides
474499 :c:member: `~PyTypeObject.tp_new ` is no longer allowed.
475500
501+
476502.. c :function :: int PyType_Freeze (PyTypeObject *type)
477503
478504 Make a type immutable: set the :c:macro: `Py_TPFLAGS_IMMUTABLETYPE ` flag.
@@ -644,6 +670,7 @@ The following functions and structs are used to create
644670 * :c:data:`Py_tp_token` (for clarity, prefer :c:data: `Py_TP_USE_SPEC `
645671 rather than ``NULL ``)
646672
673+
647674.. c:macro:: Py_tp_token
648675
649676 A :c:member:`~PyType_Slot.slot` that records a static memory layout ID
0 commit comments