[issue10144] Buffering bug after calling curses function

Ned Deily report at bugs.python.org
Tue Oct 19 22:07:52 CEST 2010


Ned Deily <nad at 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 <report at bugs.python.org>
<http://bugs.python.org/issue10144>
_______________________________________


More information about the Python-bugs-list mailing list