[docs] Improve doc for str(bytesobject) (issue 13538)

chris.jerdonek at gmail.com chris.jerdonek at gmail.com
Sun Nov 18 03:00:46 CET 2012


http://bugs.python.org/review/13538/diff/6548/Doc/library/functions.rst
File Doc/library/functions.rst (right):

http://bugs.python.org/review/13538/diff/6548/Doc/library/functions.rst#newcode1264
Doc/library/functions.rst:1264: :meth:`object.__str__`, which is the
"informal" representation of *object*.
On 2012/11/17 22:37:49, cjerdonek wrote:
> On 2012/11/17 17:09:02, ezio.melotti wrote:
> > Doesn't it also fall back on __repr__ if __str__ is missing?
> 
> str() (unicode_new() in the source code) only calls object.__str__()
> (PyObject_Str() in the source code):

What I wrote isn't quite correct.  str() calls PyObject_Str(), but
PyObject_Str() isn't called by object.__str__().  However,
object.__str__() (or at least the default implementation?) seems to
implement its own equivalent fallback logic:

http://hg.python.org/cpython/file/eb3714863872/Objects/typeobject.c#l5262

So in distinct ways both code paths seem to contain this fallback logic.

http://bugs.python.org/review/13538/


More information about the docs mailing list