[IPython-User] Stdout not immediately appearing using %run in IPython 0.10.1

Wes McKinney wesmckinn@gmail....
Mon Oct 18 23:01:13 CDT 2010


On Mon, Oct 18, 2010 at 8:17 PM, Fernando Perez <fperez.net@gmail.com> wrote:
> On Sun, Oct 17, 2010 at 11:13 AM, Wes McKinney <wesmckinn@gmail.com> wrote:
>> I confirmed this problem on the stock Python 2.6.5 bundled with Ubuntu
>> 10.04. Same issue if you call the built-in execfile instead of %run--
>> and sys.stdout is the only thing affected (if i change print to
>> sys.stderr.write(...) then that's fine).
>
> It seems to be a curses bug in Python itself, not an IPython-specific issue:
>
> uqbar[~]> cat bufferbug.py
> """Strange bug in buffering of sys.stdout after calling curses functions.
> """
> import time
> import curses
>
> def bug():
>    curses.initscr()
>    curses.endwin()
>
> def f(n=2):
>    s = 0.75
>    for i in range(n):
>        print i
>        time.sleep(s)
>    print i+1
>
> if __name__ == '__main__':
>    f()
>    print 'Calling bug() now!'
>    bug()
>    f()
>
> ####
>
> Just run with python, no ipython involved, and you'll see the problem.
>
> This is very annoying: we need to use curses to determine window size,
> and this bug seems to persist.  So once we've called curses once,
> we're stuck with the problem.
>
> The good news:  I just tested, and 3.1 doesn't show the problem.
> The bad news:  I just tested, and 2.7 does show the problem.
>
> Care to file a bug report with python itself?  Who knows, there might
> be a fix for the 2.7 series at least...
>
> I've spent a fair amount of time trying to find anything I could call
> in curses to work around this, but so far without success.  If anyone
> knows of something we could do from our side (rather than just waiting
> for Python itself to get fixed or to be all on Python3) by all means
> let us know.
>
> Cheers,
>
>

Thanks so much Fernando for tracking this down (and for reading my
e-mail, scipy.org doesn't let my e-mails through regularly). Indeed
this is very irritating (makes me say "curses"), I'd be happy to file
a bug report on python.org if that's the right thing to do.

I'm kind of surprised that this was not a known issue (I was thinking
maybe it's something wrong with my configuration). Surely I can't be
the one running long-ish scripts with progress output (after using ?
magic)?

Thanks again
Wes


More information about the IPython-User mailing list