gh-130821: Add type information to error messages for invalid return type (GH-130835)

This commit is contained in:
Semyon Moroz
2025-08-14 08:04:41 +00:00
committed by GitHub
parent c9d7065188
commit 968f6e523a
14 changed files with 76 additions and 76 deletions

View File

@@ -1329,8 +1329,9 @@ module_get_annotations(PyObject *self, void *Py_UNUSED(ignored))
return NULL;
}
if (!PyDict_Check(annotations)) {
PyErr_Format(PyExc_TypeError, "__annotate__ returned non-dict of type '%.100s'",
Py_TYPE(annotations)->tp_name);
PyErr_Format(PyExc_TypeError,
"__annotate__() must return a dict, not %T",
annotations);
Py_DECREF(annotate);
Py_DECREF(annotations);
Py_DECREF(dict);