summaryrefslogtreecommitdiffstats
path: root/Objects/stringobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-05-01 16:51:53 (GMT)
committerGuido van Rossum <guido@python.org>2001-05-01 16:51:53 (GMT)
commit189f1df3018885335bc9e719a96e891e3812ce1a (patch)
tree521ebb6d80e8319b76ebc52a4958a0301a2e5c1d /Objects/stringobject.c
parent09e563abb450ab9978c9fd7589a8c88e12c60c21 (diff)
downloadcpython-189f1df3018885335bc9e719a96e891e3812ce1a.zip
cpython-189f1df3018885335bc9e719a96e891e3812ce1a.tar.gz
cpython-189f1df3018885335bc9e719a96e891e3812ce1a.tar.bz2
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().
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r--Objects/stringobject.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index cb781ed..bf5056e 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -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*/