Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8f790fe

Browse files
committed
Drop back to old version of wrapper(); ESR reports that it broke things,
and I lack the time to track down the cause.
1 parent 7fd7e36 commit 8f790fe

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

Lib/curses/wrapper.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)