Ned Deily <n...@acm.org> added the comment:

The problem is reproducible with the python2 versions I have access to, that 
is, on Mac OS X and Debian Linux, and likewise not with any of the python3 3.1 
and 3.2 versions.  It is most likely due to the underlying ncurses library 
interacting with the libc stdio, maybe changing the buffer size of the stdout 
file. The output is flushed as expected if the program is changed to use the 
python2.7 io module to write to stdout, like python3 does, rather than print 
which uses the 'file' object.  As a workaround on python2, it looks like the 
expected behavior can be restored by closing and reopening sys.stdout with 
something like this:

   f()
   stdout=sys.stdout
   print('Calling bug() now!')
   bug()
   fn = sys.stdout.fileno()
   sys.stdout.close()
   sys.stdout = os.fdopen(fn,'a')
   f()

----------
nosy: +akuchling, ned.deily, pitrou
versions:  -Python 2.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10144>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to