]> granicus.if.org Git - python/commit
SF bug [#468061] __str__ ignored in str subclass.
authorTim Peters <tim.peters@gmail.com>
Tue, 16 Oct 2001 20:18:24 +0000 (20:18 +0000)
committerTim Peters <tim.peters@gmail.com>
Tue, 16 Oct 2001 20:18:24 +0000 (20:18 +0000)
commitc993315b188b08b6d78248522f6d0ed31d52f939
tree3fd0205ab57b86f588c32a378186c3569ad1d9ed
parentdfefc06fe01fdab0171a368c642ecaf352540627
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.
Lib/test/test_descr.py
Objects/object.c
Objects/stringobject.c