[Python-bugs-list] [ python-Bugs-480215 ] softspace confused in nested print

noreply@sourceforge.net noreply@sourceforge.net
Fri, 09 Nov 2001 14:33:50 -0800


Bugs item #480215, was opened at 2001-11-09 14:33
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=480215&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Tim Peters (tim_one)
Assigned to: Nobody/Anonymous (nobody)
Summary: softspace confused in nested print

Initial Comment:
Adapted from a c.l.py report:

class C:
.   def __str__(self):
.       print "a"
.       return "b"
print C()

The output is " a\nb\n" -- note the surprising leading 
space.  This is because PRINT_ITEM forces softspace to 
1 *before* converting the output item (so softspace is 
1 when we get into __str__, despite that nothing yet 
has been written).

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=480215&group_id=5470