]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Printing objects to a real file still wasn't done right: if the
authorGuido van Rossum <guido@python.org>
Tue, 1 May 2001 16:53:37 +0000 (16:53 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 1 May 2001 16:53:37 +0000 (16:53 +0000)
commit4f288ab7d6b386e223a187523daf894e012f8cfd
treebaf04dfbdeaab91767af7ddbc3e146cc1fdbac2c
parent189f1df3018885335bc9e719a96e891e3812ce1a
Printing objects to a real file still wasn't done right: if the
object's type didn't define tp_print, there were still cases where the
full "print uses str() which falls back to repr()" semantics weren't
honored.  This resulted in

    >>> print None
    <None object at 0x80bd674>
    >>> print type(u'')
    <type object at 0x80c0a80>

Fixed this by always using the appropriate PyObject_Repr() or
PyObject_Str() call, rather than trying to emulate what they would do.

Also simplified PyObject_Str() to always fall back on PyObject_Repr()
when tp_str is not defined (rather than making an extra check for
instances with a __str__ method).  And got rid of the special case for
strings.
Objects/object.c