[Python-checkins] (2.7): Issue #5622: Fix curses.wrapper to raise correct exception if curses

ned.deily python-checkins at python.org
Wed Mar 9 11:33:57 CET 2011


http://hg.python.org/cpython/rev/c731e02472c5
changeset:   68338:c731e02472c5
branch:      2.7
parent:      68334:c8b651b3a493
user:        Ned Deily <nad at acm.org>
date:        Wed Mar 09 02:31:55 2011 -0800
summary:
  Issue #5622: Fix curses.wrapper to raise correct exception if curses
initialization fails.

files:
  Lib/curses/wrapper.py
  Misc/NEWS

diff --git a/Lib/curses/wrapper.py b/Lib/curses/wrapper.py
--- a/Lib/curses/wrapper.py
+++ b/Lib/curses/wrapper.py
@@ -43,7 +43,8 @@
         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()
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -40,6 +40,9 @@
 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.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list