diff options
author | Benjamin Peterson <benjamin@python.org> | 2020-09-02 16:29:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-02 16:29:06 (GMT) |
commit | 3940333637b98a2781869977b077552514784529 (patch) | |
tree | 3b2c264f2acccc540076922a08d7e45e477ad4b1 /Modules/_testcapimodule.c | |
parent | 5a4a963a6c798fa9207a9998618a9c0ec3b6b6d7 (diff) | |
download | cpython-3940333637b98a2781869977b077552514784529.zip cpython-3940333637b98a2781869977b077552514784529.tar.gz cpython-3940333637b98a2781869977b077552514784529.tar.bz2 |
closes bpo-41689: Preserve text signature from tp_doc in C heap type creation. (GH-22058)
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r-- | Modules/_testcapimodule.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 593034e..7536d29 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -6462,6 +6462,30 @@ static PyTypeObject MethodDescriptor2_Type = { .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_VECTORCALL, }; +PyDoc_STRVAR(heapdocctype__doc__, +"HeapDocCType(arg1, arg2)\n" +"--\n" +"\n" +"somedoc"); + +typedef struct { + PyObject_HEAD +} HeapDocCTypeObject; + +static PyType_Slot HeapDocCType_slots[] = { + {Py_tp_doc, (char*)heapdocctype__doc__}, + {0}, +}; + +static PyType_Spec HeapDocCType_spec = { + "_testcapi.HeapDocCType", + sizeof(HeapDocCTypeObject), + 0, + Py_TPFLAGS_DEFAULT, + HeapDocCType_slots +}; + + PyDoc_STRVAR(heapgctype__doc__, "A heap type with GC, and with overridden dealloc.\n\n" "The 'value' attribute is set to 10 in __init__."); @@ -7130,6 +7154,12 @@ PyInit__testcapi(void) Py_INCREF(TestError); PyModule_AddObject(m, "error", TestError); + PyObject *HeapDocCType = PyType_FromSpec(&HeapDocCType_spec); + if (HeapDocCType == NULL) { + return NULL; + } + PyModule_AddObject(m, "HeapDocCType", HeapDocCType); + PyObject *HeapGcCType = PyType_FromSpec(&HeapGcCType_spec); if (HeapGcCType == NULL) { return NULL; |