diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-03-24 19:25:00 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-03-24 19:25:00 (GMT) |
commit | 8e5fd53be00001cbfa9368bd64f67cdef5d46771 (patch) | |
tree | f4182ff5d75144a6ddb1778ba23eb6beb64f1c9a /Lib/test/test_softspace.py | |
parent | f3f87f743efc252a0f4fa62719a2f9cf52df3f85 (diff) | |
download | cpython-8e5fd53be00001cbfa9368bd64f67cdef5d46771.zip cpython-8e5fd53be00001cbfa9368bd64f67cdef5d46771.tar.gz cpython-8e5fd53be00001cbfa9368bd64f67cdef5d46771.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/test_softspace.py')
-rw-r--r-- | Lib/test/test_softspace.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_softspace.py b/Lib/test/test_softspace.py new file mode 100644 index 0000000..ba860eb --- /dev/null +++ b/Lib/test/test_softspace.py @@ -0,0 +1,14 @@ +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') |