diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-05-04 12:29:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-04 12:29:56 (GMT) |
commit | 912ef3f2481a30362bce339fd44aba990d046ae2 (patch) | |
tree | bc345615db562f83c285f6ff22ee396ce4a8ab15 /Modules | |
parent | ae4f8574993c85f9dc6fe60e6a25d65f688705e6 (diff) | |
download | cpython-912ef3f2481a30362bce339fd44aba990d046ae2.zip cpython-912ef3f2481a30362bce339fd44aba990d046ae2.tar.gz cpython-912ef3f2481a30362bce339fd44aba990d046ae2.tar.bz2 |
Add C-API tests (GH-25886) (#25887)
(cherry picked from commit 2f5baa17504feb9a7613bac32fdceed4894434de)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 26ebacb..0a3040f 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -3861,6 +3861,25 @@ test_structseq_newtype_doesnt_leak(PyObject *Py_UNUSED(self), } static PyObject * +test_structseq_newtype_null_descr_doc(PyObject *Py_UNUSED(self), + PyObject *Py_UNUSED(args)) +{ + PyStructSequence_Field descr_fields[1] = { + (PyStructSequence_Field){NULL, NULL} + }; + // Test specifically for NULL .doc field. + PyStructSequence_Desc descr = {"_testcapi.test_descr", NULL, &descr_fields[0], 0}; + + PyTypeObject* structseq_type = PyStructSequence_NewType(&descr); + assert(structseq_type != NULL); + assert(PyType_Check(structseq_type)); + assert(PyType_FastSubclass(structseq_type, Py_TPFLAGS_TUPLE_SUBCLASS)); + Py_DECREF(structseq_type); + + Py_RETURN_NONE; +} + +static PyObject * test_incref_decref_API(PyObject *ob, PyObject *Py_UNUSED(ignored)) { PyObject *obj = PyLong_FromLong(0); @@ -5618,6 +5637,8 @@ 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_structseq_newtype_null_descr_doc", + test_structseq_newtype_null_descr_doc, 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}, |