- Use %T format specifier instead of %s and Py_TYPE(x)->tp_name.
- Remove legacy %.200s format specifier for truncating type names.
Co-authored-by: Victor Stinner <vstinner@python.org>
type_error:
PyErr_Format(PyExc_TypeError,
- "cannot index memory using \"%.200s\"",
- Py_TYPE(key)->tp_name);
+ "cannot index memory using \"%T\"", key);
err_occurred:
Py_DECREF(nd);
return NULL;
};
#define RAISE_UNLESS_CODELIKE(v) if (!Py_IS_TYPE((v), &PyCodeLike_Type)) { \
- PyErr_Format(PyExc_TypeError, "expected a code-like, got %s", Py_TYPE(v)->tp_name); \
+ PyErr_Format(PyExc_TypeError, "expected a code-like, got %T", v); \
return NULL; \
}
pytime_from_nanoseconds(PyTime_t *tp, PyObject *obj)
{
if (!PyLong_Check(obj)) {
- PyErr_Format(PyExc_TypeError, "expect int, got %s",
- Py_TYPE(obj)->tp_name);
+ PyErr_Format(PyExc_TypeError, "expect int, got %T", obj);
return -1;
}
return NULL;
if (!PyCallable_Check(fn)) {
- PyErr_Format(PyExc_TypeError, "'%s' object is not callable",
- Py_TYPE(fn)->tp_name);
+ PyErr_Format(PyExc_TypeError, "'%T' object is not callable", fn);
return NULL;
}
return (PyCodeObject *)PyFunction_GetCode(obj);
}
return (PyCodeObject *)PyErr_Format(
- PyExc_TypeError, "expected function or code object, got %s",
- Py_TYPE(obj)->tp_name);
+ PyExc_TypeError, "expected function or code object, got %T", obj);
}
static PyObject *