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

ned.deily python-checkins at python.org
Wed Mar 9 11:50:45 CET 2011


http://hg.python.org/cpython/rev/6b6b8af33811
changeset:   68339:6b6b8af33811
branch:      3.1
parent:      68335:16f8f359db9c
user:        Ned Deily <nad at acm.org>
date:        Wed Mar 09 02:36:51 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
@@ -37,6 +37,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