From: Ned Deily Date: Wed, 9 Mar 2011 10:36:51 +0000 (-0800) Subject: Issue #5622: Fix curses.wrapper to raise correct exception if curses X-Git-Tag: v3.2.1b1~333^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d2853180dfd905d07aa07d6f95cc4736d5363f22;p=thirdparty%2FPython%2Fcpython.git Issue #5622: Fix curses.wrapper to raise correct exception if curses initialization fails. --- diff --git a/Lib/curses/wrapper.py b/Lib/curses/wrapper.py index 3cdaa82d0a85..5183ce741f94 100644 --- a/Lib/curses/wrapper.py +++ b/Lib/curses/wrapper.py @@ -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() diff --git a/Misc/NEWS b/Misc/NEWS index 5a445ee8fd00..c4a271baf5c7 100644 --- 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.