PyObject *name = PyModule_GetNameObject(callable);
PyObject *attr = NULL;
int suggestion = 0;
if (name != NULL) {
int res = _PyObject_LookupAttr(callable, name, &attr);
if (res > 0 && PyCallable_Check(attr)) {
_PyErr_Format(tstate, PyExc_TypeError,
"'%.200s' object is not callable. "
"Did you mean: '%U.%U(...)'?",
Py_TYPE(callable)->tp_name, name, name);
suggestion = 1;
}
}
Py_XDECREF(attr);
Py_XDECREF(name);
if (suggestion == 0) {
_PyErr_Format(tstate, PyExc_TypeError, "'%.200s' object is not callable",
Py_TYPE(callable)->tp_name);
}