[Python-checkins] CVS: python/dist/src/Lib/test test_softspace.py,NONE,1.1

Tim Peters tim_one@users.sourceforge.net
Sun, 24 Mar 2002 11:25:02 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv28901/python/Lib/test

Added Files:
	test_softspace.py 
Log Message:
SF bug 480215:  softspace confused in nested print
This fixes the symptom, but PRINT_ITEM has no way to know what (if
anything) PyFile_WriteObject() writes unless the object being printed
is a string.  When the object isn't a string, this fix retains the
guess that softspace should be set after PyFile_WriteObject().
We might want to say that it's the job of filelike-object write methods
to leave the file's softspace in the correct state.  That would probably
be better -- but everyone relies on PRINT_ITEM to guess for them now.


--- NEW FILE: test_softspace.py ---
import test_support
import StringIO

# SF bug 480215:  softspace confused in nested print
f = StringIO.StringIO()
class C:
    def __str__(self):
        print >> f, 'a'
        return 'b'

print >> f, C(), 'c ', 'd\t', 'e'
print >> f, 'f', 'g'
# In 2.2 & earlier, this printed ' a\nbc  d\te\nf g\n'
test_support.vereq(f.getvalue(), 'a\nb c  d\te\nf g\n')