Issue #10833: Use PyErr_Format() and PyUnicode_FromFormat() instead of

PyOS_snprintf() to avoid temporary buffer allocated on the stack and a
conversion from bytes to Unicode.
This commit is contained in:
Victor Stinner 2011-03-21 18:15:42 +01:00
parent 44afe2b35a
commit 6ced7c4333
6 changed files with 36 additions and 65 deletions

View file

@ -2400,11 +2400,9 @@ static PyObject *
Tktt_Repr(PyObject *self)
{
TkttObject *v = (TkttObject *)self;
char buf[100];
PyOS_snprintf(buf, sizeof(buf), "<tktimertoken at %p%s>", v,
v->func == NULL ? ", handler deleted" : "");
return PyUnicode_FromString(buf);
return PyUnicode_FromFormat("<tktimertoken at %p%s>",
v,
v->func == NULL ? ", handler deleted" : "");
}
static PyTypeObject Tktt_Type =