Skip to content

Commit dabfb67

Browse files
committed
apply victor's comment
1 parent e604f31 commit dabfb67

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

Doc/whatsnew/3.10.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ New Features
366366
* Added :c:func:`PyUnicode_AsUTF8AndSize` to the limited C API.
367367
(Contributed by Alex Gaynor in :issue:`41784`.)
368368

369-
* The :c:func:`PyType_FromModuleAndSpec` function can accept tp_doc=NULL.
369+
* The :c:func:`PyType_FromModuleAndSpec` function now accepts NULL ``tp_doc``
370+
slot.
370371
(Contributed by Hai Shi in :issue:`41832`.)
371372

372373

Modules/_lsprof.c

-2
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,12 @@ static PyStructSequence_Field profiler_subentry_fields[] = {
489489

490490
static PyStructSequence_Desc profiler_entry_desc = {
491491
.name = "_lsprof.profiler_entry",
492-
.doc = "",
493492
.fields = profiler_entry_fields,
494493
.n_in_sequence = 6
495494
};
496495

497496
static PyStructSequence_Desc profiler_subentry_desc = {
498497
.name = "_lsprof.profiler_subentry",
499-
.doc = "",
500498
.fields = profiler_subentry_fields,
501499
.n_in_sequence = 5
502500
};

Modules/_testcapimodule.c

+15-4
Original file line numberDiff line numberDiff line change
@@ -3987,10 +3987,20 @@ test_structseq_newtype_doesnt_leak(PyObject *Py_UNUSED(self),
39873987
assert(PyType_FastSubclass(structseq_type, Py_TPFLAGS_TUPLE_SUBCLASS));
39883988
Py_DECREF(structseq_type);
39893989

3990-
descr.doc = NULL;
3991-
structseq_type = PyStructSequence_NewType(&descr);
3992-
assert(structseq_type != NULL);
3993-
Py_DECREF(structseq_type);
3990+
Py_RETURN_NONE;
3991+
}
3992+
3993+
static PyType_Spec HeapDocCType_spec;
3994+
3995+
static PyObject *
3996+
test_PyType_FromSpec(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(args))
3997+
{
3998+
void *tp_doc = HeapDocCType_spec.slots[0].pfunc;
3999+
HeapDocCType_spec.slots[0].pfunc = NULL;
4000+
PyObject *HeapDocCType = PyType_FromSpec(&HeapDocCType_spec);
4001+
assert(HeapDocCType != NULL);
4002+
HeapDocCType_spec.slots[0].pfunc = tp_doc;
4003+
Py_DECREF(HeapDocCType);
39944004

39954005
Py_RETURN_NONE;
39964006
}
@@ -5606,6 +5616,7 @@ static PyMethodDef TestMethods[] = {
56065616
{"test_decref_doesnt_leak", test_decref_doesnt_leak, METH_NOARGS},
56075617
{"test_structseq_newtype_doesnt_leak",
56085618
test_structseq_newtype_doesnt_leak, METH_NOARGS},
5619+
{"test_PyType_FromSpec", test_PyType_FromSpec, METH_NOARGS},
56095620
{"test_incref_decref_API", test_incref_decref_API, METH_NOARGS},
56105621
{"test_long_and_overflow", test_long_and_overflow, METH_NOARGS},
56115622
{"test_long_as_double", test_long_as_double, METH_NOARGS},

0 commit comments

Comments
 (0)