Add a proper implementation for the tp_str slot (returning self, of
authorGuido van Rossum <guido@python.org>
Tue, 1 May 2001 16:51:53 +0000 (16:51 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 1 May 2001 16:51:53 +0000 (16:51 +0000)
course), so I can get rid of the special case for strings in
PyObject_Str().

Objects/stringobject.c

index cb781ed64532f79c18926ce25a565686bc1ae945..bf5056e586b7c34e2c184944589d055a793ba05f 100644 (file)
@@ -401,6 +401,13 @@ string_repr(register PyStringObject *op)
        }
 }
 
+static PyObject *
+string_str(PyObject *s)
+{
+       Py_INCREF(s);
+       return s;
+}
+
 static int
 string_length(PyStringObject *a)
 {
@@ -2374,7 +2381,7 @@ PyTypeObject PyString_Type = {
        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*/