mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
repr's converted to using PyString_FromFormat() instead of sprintf'ing
into a hardcoded char* buffer. Closes patch #454743.
This commit is contained in:
parent
dadace004b
commit
7ce3694a52
11 changed files with 95 additions and 136 deletions
|
@ -222,6 +222,7 @@ void _PyGC_Dump(PyGC_Head* op)
|
|||
}
|
||||
#endif /* WITH_CYCLE_GC */
|
||||
|
||||
|
||||
PyObject *
|
||||
PyObject_Repr(PyObject *v)
|
||||
{
|
||||
|
@ -235,12 +236,9 @@ PyObject_Repr(PyObject *v)
|
|||
#endif
|
||||
if (v == NULL)
|
||||
return PyString_FromString("<NULL>");
|
||||
else if (v->ob_type->tp_repr == NULL) {
|
||||
char buf[120];
|
||||
sprintf(buf, "<%.80s object at %p>",
|
||||
v->ob_type->tp_name, v);
|
||||
return PyString_FromString(buf);
|
||||
}
|
||||
else if (v->ob_type->tp_repr == NULL)
|
||||
return PyString_FromFormat("<%s object at %p",
|
||||
v->ob_type->tp_name, v);
|
||||
else {
|
||||
PyObject *res;
|
||||
res = (*v->ob_type->tp_repr)(v);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue