report at bugs.python.org
Sat Apr 19 00:51:09 CEST 2008
New submission from Fernando Pérez <fer_perez at users.sourceforge.net>:
Curses sometimes fails to correctly initialize the terminal.
Unfortunately I don't know how to reproduce the problem, it was reported
multiple times by ipython users, but I have no idea what causes it. I
finally found a workaround by making a termios call that at least
restores terminal state (see attachment), but it's just a workaround,
not a real fix.
The issue manifests itself as follows: at some point (I don't know why),
a call to curses.initscr() doesn't actually set the terminal in the
usual mode where input isn't accepted, but instead the terminal
continues accepting normal input, issuing newlines, etc. The only sign
that curses is active is that in a modern terminal, the scrollbar
changes to fill the screen. After this, calling curses.endwin(),
instead of restoring terminal state, leaves the terminal in the mode
that typically initscr() would put it in: no input is displayed,
printouts swallow end-of-line characters, etc.
When this happened in ipython sessions, we'd just suggest users call
!reset (the system command), which would restore terminal state. But
the problem is obviously in curses itself, because once this problem
appeared, running the attached script would always print 'False' for the
state condition checked there.
For now in IPython we have a workaround, but perhaps with this little
description/example, someone who knows the curses code might be able to
actually fix the real problem. If I find a reliable way to trigger the
bug, I'll add comments here indicating so.
components: Extension Modules
versions: Python 2.5
Added file: http://bugs.python.org/file10059/cursesbug.py
Tracker <report at bugs.python.org>
More information about the Python-bugs-list