File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,9 +17,11 @@ def wrapper(func, *rest):
1717 wrapper().
1818 """
1919
20+ res = None
2021 try :
2122 # Initialize curses
2223 stdscr = curses .initscr ()
24+
2325 # Turn off echoing of keys, and enter cbreak mode,
2426 # where no buffering is performed on keyboard input
2527 curses .noecho () ; curses .cbreak ()
@@ -29,11 +31,21 @@ def wrapper(func, *rest):
2931 # a special value like curses.KEY_LEFT will be returned
3032 stdscr .keypad (1 )
3133
32- return apply (func , (stdscr ,) + rest )
33-
34- finally :
35- # Restore the terminal to a sane state on the way out .
34+ res = apply (func , (stdscr ,) + rest )
35+ except :
36+ # In the event of an error, restore the terminal
37+ # to a sane state.
3638 stdscr .keypad (0 )
3739 curses .echo () ; curses .nocbreak ()
3840 curses .endwin ()
41+
42+ # Pass the exception upwards
43+ (exc_type , exc_value , exc_traceback ) = sys .exc_info ()
44+ raise exc_type , exc_value , exc_traceback
45+ else :
46+ # Set everything back to normal
47+ stdscr .keypad (0 )
48+ curses .echo () ; curses .nocbreak ()
49+ curses .endwin () # Terminate curses
3950
51+ return res
You can’t perform that action at this time.
0 commit comments