Skip to content

Commit 09ad235

Browse files
author
Michael W. Hudson
committed
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.
1 parent 6f937b1 commit 09ad235

1 file changed

Lines changed: 4 additions & 17 deletions

File tree

Lib/curses/wrapper.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import 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()

0 commit comments

Comments
 (0)