"""Try to illustrate a curses bug. This would often occur in long-running ipython sessions, but I have no idea how to reliably reproduce it. """ import _curses as curses import sys import termios flags0 = termios.tcgetattr(sys.stdout) curses.initscr() curses.endwin() flags1 = termios.tcgetattr(sys.stdout) print 'Is the terminal final state correctly restored ?',flags0==flags1 # Restore terminal state termios.tcsetattr(sys.stdout,termios.TCSANOW,flags0)