diff Objects/stringobject.c @ 17645:b5f583eecb20 legacy-trunk

Add a proper implementation for the tp_str slot (returning self, of course), so I can get rid of the special case for strings in PyObject_Str().
author Guido van Rossum <guido@python.org>
date Tue, 01 May 2001 16:51:53 +0000
parents 9934225fe297
children 0470babdae49
line wrap: on
line diff
--- a/Objects/stringobject.c	Tue May 01 12:10:21 2001 +0000
+++ b/Objects/stringobject.c	Tue May 01 16:51:53 2001 +0000
@@ -401,6 +401,13 @@
 	}
 }
 
+static PyObject *
+string_str(PyObject *s)
+{
+	Py_INCREF(s);
+	return s;
+}
+
 static int
 string_length(PyStringObject *a)
 {
@@ -2374,7 +2381,7 @@
 	0,		/*tp_as_mapping*/
 	(hashfunc)string_hash, /*tp_hash*/
 	0,		/*tp_call*/
-	0,		/*tp_str*/
+	(reprfunc)string_str,	/*tp_str*/
 	0,		/*tp_getattro*/
 	0,		/*tp_setattro*/
 	&string_as_buffer,	/*tp_as_buffer*/