summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2004-08-07 15:18:07 (GMT)
committerMichael W. Hudson <mwh@python.net>2004-08-07 15:18:07 (GMT)
commit09ad235f9976d55944be3104d9911dab10c1fa55 (patch)
treee7028f42e1c52380e664d22eb81f3a4e703afb9d /Lib
parent6f937b1c3038445e59a1bd593c26d6806548b25c (diff)
downloadcpython-09ad235f9976d55944be3104d9911dab10c1fa55.zip
cpython-09ad235f9976d55944be3104d9911dab10c1fa55.tar.gz
cpython-09ad235f9976d55944be3104d9911dab10c1fa55.tar.bz2
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.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/curses/wrapper.py21
1 files changed, 4 insertions, 17 deletions
diff --git a/Lib/curses/wrapper.py b/Lib/curses/wrapper.py
index b8905fb..0d004e0 100644
--- a/Lib/curses/wrapper.py
+++ b/Lib/curses/wrapper.py
@@ -9,7 +9,7 @@ to a sane state so you can read the resulting traceback.
import sys, curses
-def wrapper(func, *rest):
+def wrapper(func, *args, **kwds):
"""Wrapper function that initializes curses and calls another function,
restoring normal keyboard/screen behavior on error.
The callable object 'func' is then passed the main window 'stdscr'
@@ -41,23 +41,10 @@ def wrapper(func, *rest):
except:
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:
+ return func(stdscr, *rest)
+ finally:
# Set everything back to normal
stdscr.keypad(0)
curses.echo()
curses.nocbreak()
- curses.endwin() # Terminate curses
-
- return res
+ curses.endwin()