]> granicus.if.org Git - python/commitdiff
Issue #5622: Fix curses.wrapper to raise correct exception if curses
authorNed Deily <nad@acm.org>
Wed, 9 Mar 2011 10:36:51 +0000 (02:36 -0800)
committerNed Deily <nad@acm.org>
Wed, 9 Mar 2011 10:36:51 +0000 (02:36 -0800)
initialization fails.

Lib/curses/wrapper.py
Misc/NEWS

index 3cdaa82d0a856e2b18b480ffbaee646af77ebe73..5183ce741f945fd58bbba4db5bb86e38044fb549 100644 (file)
@@ -43,7 +43,8 @@ def wrapper(func, *args, **kwds):
         return func(stdscr, *args, **kwds)
     finally:
         # Set everything back to normal
-        stdscr.keypad(0)
-        curses.echo()
-        curses.nocbreak()
-        curses.endwin()
+        if 'stdscr' in locals():
+            stdscr.keypad(0)
+            curses.echo()
+            curses.nocbreak()
+            curses.endwin()
index 5a445ee8fd00974776feff43d454c30522e2c30e..c4a271baf5c7a62b4abacf8f6aab821ccf778d00 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -37,6 +37,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #5622: Fix curses.wrapper to raise correct exception if curses
+  initialization fails.
+
 - Issue #11391: Writing to a mmap object created with
   ``mmap.PROT_READ|mmap.PROT_EXEC`` would segfault instead of raising a
   TypeError.  Patch by Charles-François Natali.