Skip to content

Commit

Permalink
apply victor's comment
Browse files Browse the repository at this point in the history
  • Loading branch information
shihai1991 committed Nov 3, 2020
1 parent e604f31 commit dabfb67
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
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.
(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",
.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;
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

0 comments on commit dabfb67

Please sign in to comment.