[Python-checkins] python/dist/src/Lib/curses wrapper.py,1.7,1.8

mwh at users.sourceforge.net mwh at users.sourceforge.net
Sat Aug 7 17:18:10 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib/curses
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3856

Modified Files:
	wrapper.py 
Log Message:
This is patch 

[ 1005008 ] curses.wrapper should also forward keyword args 

Plus my rewrite to use finally as opposed to painfully doing the
equivalent by hand.


Index: wrapper.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/curses/wrapper.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** wrapper.py	6 Apr 2003 09:00:47 -0000	1.7
--- wrapper.py	7 Aug 2004 15:18:07 -0000	1.8
***************
*** 10,14 ****
  import sys, curses
  
! def wrapper(func, *rest):
      """Wrapper function that initializes curses and calls another function,
      restoring normal keyboard/screen behavior on error.
--- 10,14 ----
  import sys, curses
  
! def wrapper(func, *args, **kwds):
      """Wrapper function that initializes curses and calls another function,
      restoring normal keyboard/screen behavior on error.
***************
*** 42,63 ****
              pass
  
!         res = func(stdscr, *rest)
!     except:
!         # In the event of an error, restore the terminal
!         # to a sane state.
!         stdscr.keypad(0)
!         curses.echo()
!         curses.nocbreak()
!         curses.endwin()
! 
!         # Pass the exception upwards
!         (exc_type, exc_value, exc_traceback) = sys.exc_info()
!         raise exc_type, exc_value, exc_traceback
!     else:
          # Set everything back to normal
          stdscr.keypad(0)
          curses.echo()
          curses.nocbreak()
!         curses.endwin()          # Terminate curses
! 
!         return res
--- 42,50 ----
              pass
  
!         return func(stdscr, *rest)
!     finally:
          # Set everything back to normal
          stdscr.keypad(0)
          curses.echo()
          curses.nocbreak()
!         curses.endwin()



More information about the Python-checkins mailing list