Ticket #27251: genutils_curses.patch

File genutils_curses.patch, 1.5 KB (added by jjstickel@…, 14 years ago)

the patchfile

  • genutils.py

    old new  
    16681668            # unconditionally reset it every time.  It's cheaper than making
    16691669            # the checks.
    16701670            term_flags = termios.tcgetattr(sys.stdout)
     1671           
     1672            # Curses modifies the stdout buffer size by default, which messes
     1673            # up Python's normal stdout buffering. This would manifest itself
     1674            # to IPython users as delayed printing on stdout after having used
     1675            # the pager.
     1676            #
     1677            # We can prevent this by manually setting the NCURSES_NO_SETBUF
     1678            # environment variable. For more details, see:
     1679            # http://bugs.python.org/issue10144
     1680            NCURSES_NO_SETBUF = os.environ.get('NCURSES_NO_SETBUF', None)
     1681            os.environ['NCURSES_NO_SETBUF'] = ''
     1682           
     1683            # Proceed with curses initialization
    16711684            scr = curses.initscr()
    16721685            screen_lines_real,screen_cols = scr.getmaxyx()
    16731686            curses.endwin()
     1687           
     1688            # Restore environment
     1689            if NCURSES_NO_SETBUF is None:
     1690                del os.environ['NCURSES_NO_SETBUF']
     1691            else:
     1692                os.environ['NCURSES_NO_SETBUF'] = NCURSES_NO_SETBUF
     1693               
    16741694            # Restore terminal state in case endwin() didn't.
    16751695            termios.tcsetattr(sys.stdout,termios.TCSANOW,term_flags)
    16761696            # Now we have what we needed: the screen size in rows/columns