File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99
1010import sys , curses
1111
12- def wrapper (func , * rest ):
12+ def wrapper (func , * args , ** kwds ):
1313 """Wrapper function that initializes curses and calls another function,
1414 restoring normal keyboard/screen behavior on error.
1515 The callable object 'func' is then passed the main window 'stdscr'
@@ -41,23 +41,10 @@ def wrapper(func, *rest):
4141 except :
4242 pass
4343
44- res = func (stdscr , * rest )
45- except :
46- # In the event of an error, restore the terminal
47- # to a sane state.
48- stdscr .keypad (0 )
49- curses .echo ()
50- curses .nocbreak ()
51- curses .endwin ()
52-
53- # Pass the exception upwards
54- (exc_type , exc_value , exc_traceback ) = sys .exc_info ()
55- raise exc_type , exc_value , exc_traceback
56- else :
44+ return func (stdscr , * rest )
45+ finally :
5746 # Set everything back to normal
5847 stdscr .keypad (0 )
5948 curses .echo ()
6049 curses .nocbreak ()
61- curses .endwin () # Terminate curses
62-
63- return res
50+ curses .endwin ()
You can’t perform that action at this time.
0 commit comments