diff Objects/object.c @ 19476:0e70df98424e legacy-trunk

repr's converted to using PyString_FromFormat() instead of sprintf'ing into a hardcoded char* buffer. Closes patch #454743.
author Barry Warsaw <barry@python.org>
date Fri, 24 Aug 2001 18:34:26 +0000
parents 7257e87e0720
children dc27839c0b80
line wrap: on
line diff
--- a/Objects/object.c	Fri Aug 24 18:32:06 2001 +0000
+++ b/Objects/object.c	Fri Aug 24 18:34:26 2001 +0000
@@ -222,6 +222,7 @@
 }
 #endif /* WITH_CYCLE_GC */
 
+
 PyObject *
 PyObject_Repr(PyObject *v)
 {
@@ -235,12 +236,9 @@
 #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);