Skip to content

Commit

Permalink
apply petr's comment
Browse files Browse the repository at this point in the history
  • Loading branch information
shihai1991 committed Aug 7, 2021
1 parent a940aaf commit 4cfebb2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,19 +1174,26 @@ test_get_type_qualname(PyObject *self, PyObject *Py_UNUSED(ignored))
if (HeapTypeNameType == NULL) {
Py_RETURN_NONE;
}
tp_qualname = PyType_GetQualName((PyTypeObject *)HeapTypeNameType);
assert(strcmp(PyUnicode_AsUTF8(tp_qualname), "HeapTypeNameType") == 0);
Py_DECREF(tp_qualname);

PyObject *spec_name = PyUnicode_FromString(HeapTypeNameType_Spec.name);
if (spec_name == NULL) {
goto done;
}
if (PyObject_SetAttrString(HeapTypeNameType,
"__qualname__", spec_name) < 0) {
Py_DECREF(spec_name);
Py_DECREF(HeapTypeNameType);
Py_RETURN_NONE;
goto done;
}
tp_qualname = PyType_GetQualName((PyTypeObject *)HeapTypeNameType);
assert(strcmp(PyUnicode_AsUTF8(tp_qualname),
"_testcapi.HeapTypeNameType") == 0);
Py_DECREF(spec_name);
Py_DECREF(tp_qualname);

done:
Py_DECREF(HeapTypeNameType);
Py_RETURN_NONE;
}
Expand Down

0 comments on commit 4cfebb2

Please sign in to comment.