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 3, 2020
commit dabfb676234fc23c98dbca8dbf50c7c9282990c3
3 changes: 2 additions & 1 deletion Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ New Features
* Added :c:func:`PyUnicode_AsUTF8AndSize` to the limited C API.
(Contributed by Alex Gaynor in :issue:`41784`.)

* The :c:func:`PyType_FromModuleAndSpec` function can accept tp_doc=NULL.
* The :c:func:`PyType_FromModuleAndSpec` function now accepts NULL ``tp_doc``
slot.
Comment thread
shihai1991 marked this conversation as resolved.
(Contributed by Hai Shi in :issue:`41832`.)


Expand Down
2 changes: 0 additions & 2 deletions Modules/_lsprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,14 +489,12 @@ static PyStructSequence_Field profiler_subentry_fields[] = {

static PyStructSequence_Desc profiler_entry_desc = {
.name = "_lsprof.profiler_entry",
Comment thread
shihai1991 marked this conversation as resolved.
.doc = "",
.fields = profiler_entry_fields,
.n_in_sequence = 6
};

static PyStructSequence_Desc profiler_subentry_desc = {
.name = "_lsprof.profiler_subentry",
.doc = "",
.fields = profiler_subentry_fields,
.n_in_sequence = 5
};
Expand Down
19 changes: 15 additions & 4 deletions Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3987,10 +3987,20 @@ test_structseq_newtype_doesnt_leak(PyObject *Py_UNUSED(self),
assert(PyType_FastSubclass(structseq_type, Py_TPFLAGS_TUPLE_SUBCLASS));
Py_DECREF(structseq_type);

descr.doc = NULL;
structseq_type = PyStructSequence_NewType(&descr);
assert(structseq_type != NULL);
Py_DECREF(structseq_type);
Py_RETURN_NONE;
}

static PyType_Spec HeapDocCType_spec;

static PyObject *
test_PyType_FromSpec(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args))
{
void *tp_doc = HeapDocCType_spec.slots[0].pfunc;
HeapDocCType_spec.slots[0].pfunc = NULL;
Comment thread
shihai1991 marked this conversation as resolved.
Outdated
PyObject *HeapDocCType = PyType_FromSpec(&HeapDocCType_spec);
assert(HeapDocCType != NULL);
HeapDocCType_spec.slots[0].pfunc = tp_doc;
Py_DECREF(HeapDocCType);

Py_RETURN_NONE;
}
Expand Down Expand Up @@ -5606,6 +5616,7 @@ static PyMethodDef TestMethods[] = {
{"test_decref_doesnt_leak", test_decref_doesnt_leak, METH_NOARGS},
{"test_structseq_newtype_doesnt_leak",
test_structseq_newtype_doesnt_leak, METH_NOARGS},
{"test_PyType_FromSpec", test_PyType_FromSpec, METH_NOARGS},
{"test_incref_decref_API", test_incref_decref_API, METH_NOARGS},
{"test_long_and_overflow", test_long_and_overflow, METH_NOARGS},
{"test_long_as_double", test_long_as_double, METH_NOARGS},
Expand Down