mirror of
https://github.com/python/cpython.git
synced 2024-12-12 19:33:52 +08:00
bpo-42035: Enhance test_get_type_name() of _testcapi (GH-27649)
This commit is contained in:
parent
3e2c643ae0
commit
fcd651d16f
@ -1154,6 +1154,20 @@ test_get_type_name(PyObject *self, PyObject *Py_UNUSED(ignored))
|
||||
assert(strcmp(PyUnicode_AsUTF8(tp_name), "HeapTypeNameType") == 0);
|
||||
Py_DECREF(tp_name);
|
||||
|
||||
PyObject *name = PyUnicode_FromString("test_name");
|
||||
if (name == NULL) {
|
||||
goto done;
|
||||
}
|
||||
if (PyObject_SetAttrString(HeapTypeNameType, "__name__", name) < 0) {
|
||||
Py_DECREF(name);
|
||||
goto done;
|
||||
}
|
||||
tp_name = PyType_GetName((PyTypeObject *)HeapTypeNameType);
|
||||
assert(strcmp(PyUnicode_AsUTF8(tp_name), "test_name") == 0);
|
||||
Py_DECREF(name);
|
||||
Py_DECREF(tp_name);
|
||||
|
||||
done:
|
||||
Py_DECREF(HeapTypeNameType);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user