8000 bpo-41832: PyType_FromModuleAndSpec() can accept the NULL tp_doc slot. by shihai1991 · Pull Request #23123 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
8000

bpo-41832: PyType_FromModuleAndSpec() can accept the NULL tp_doc slot. #23123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 6, 2020
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``.

.. 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);
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
0