diff options
author | Guido van Rossum <guido@python.org> | 2001-05-01 16:51:53 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-05-01 16:51:53 (GMT) |
commit | 189f1df3018885335bc9e719a96e891e3812ce1a (patch) | |
tree | 521ebb6d80e8319b76ebc52a4958a0301a2e5c1d /Objects | |
parent | 09e563abb450ab9978c9fd7589a8c88e12c60c21 (diff) | |
download | cpython-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')
-rw-r--r-- | Objects/stringobject.c | 9 |
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*/ |