Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
apply victor's comment
  • Loading branch information
shihai1991 committed Nov 5, 2020
commit cca7bc7edf11a7d212ae70dcff6f10cf96fab470
10 changes: 5 additions & 5 deletions Doc/c-api/type.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ The following functions and structs are used to create

.. versionadded:: 3.9

.. versionchanged:: 3.10

The ``Py_tp_doc`` slot now can accepts ``NULL`` value.
Previously, the slot may not be ``NULL``.
Comment thread
shihai1991 marked this conversation as resolved.
Outdated

.. c:function:: PyObject* PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)

Equivalent to ``PyType_FromModuleAndSpec(NULL, spec, bases)``.
Expand Down Expand Up @@ -259,8 +264,3 @@ The following functions and structs are used to create

The desired value of the slot. In most cases, this is a pointer
to a function.

.. versionchanged:: 3.10

The ``Py_tp_doc`` slot now can accepts ``NULL`` value.
Previously, the slot may not be ``NULL``.
2 changes: 2 additions & 0 deletions Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -7200,6 +7200,8 @@ PyInit__testcapi(void)
}
PyModule_AddObject(m, "HeapDocCType", HeapDocCType);

/* bpo-41832: Add a new type to test PyType_FromSpec()
now can accept a NULL tp_doc slot. */
PyObject *NullTpDocType = PyType_FromSpec(&NullTpDocType_spec);
Comment thread
shihai1991 marked this conversation as resolved.
if (NullTpDocType == NULL) {
return NULL;
Expand Down
2 changes: 0 additions & 2 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -3012,8 +3012,6 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
else if (slot->slot == Py_tp_doc) {
/* For the docstring slot, which usually points to a static string
literal, we need to make a copy */

/* bpo-41832: PyType_FromModuleAndSpec() can accept tp_doc=NULL. */
if (slot->pfunc == NULL) {
type->tp_doc = NULL;
continue;
Expand Down