summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-10-16 20:18:24 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-10-16 20:18:24 (GMT)
commitc993315b188b08b6d78248522f6d0ed31d52f939 (patch)
tree3fd0205ab57b86f588c32a378186c3569ad1d9ed /Objects/object.c
parentdfefc06fe01fdab0171a368c642ecaf352540627 (diff)
downloadcpython-c993315b188b08b6d78248522f6d0ed31d52f939.zip
cpython-c993315b188b08b6d78248522f6d0ed31d52f939.tar.gz
cpython-c993315b188b08b6d78248522f6d0ed31d52f939.tar.bz2
SF bug [#468061] __str__ ignored in str subclass.
object.c, PyObject_Str: Don't try to optimize anything except exact string objects here; in particular, let str subclasses go thru tp_str, same as non-str objects. This allows overrides of tp_str to take effect. stringobject.c: + string_print (str's tp_print): If the argument isn't an exact string object, get one from PyObject_Str. + string_str (str's tp_str): Make a genuine-string copy of the object if it's of a proper str subclass type. str() applied to a str subclass that doesn't override __str__ ends up here. test_descr.py: New str_of_str_subclass() test.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c6
1 files changed, 0 insertions, 6 deletions
diff --git a/Objects/object.c b/Objects/object.c
index be8eb07..af0c0bb 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -261,12 +261,6 @@ PyObject_Str(PyObject *v)
Py_INCREF(v);
return v;
}
- if (PyString_Check(v)) {
- /* For a string subtype that's not a string, return a true
- string with the same string data. */
- PyStringObject *s = (PyStringObject *)v;
- return PyString_FromStringAndSize(s->ob_sval, s->ob_size);
- }
if (v->ob_type->tp_str == NULL)
return PyObject_Repr(v);