From 9d4836e7319c2d32a2cec68a815858db4d5cbd04 Mon Sep 17 00:00:00 2001 From: Ned Deily Date: Wed, 9 Mar 2011 02:31:55 -0800 Subject: [PATCH] Issue #5622: Fix curses.wrapper to raise correct exception if curses initialization fails. --- Lib/curses/wrapper.py | 9 +++++---- Misc/NEWS | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Lib/curses/wrapper.py b/Lib/curses/wrapper.py index 3cdaa82d0a..5183ce741f 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 d562026ff8..10f7d6b2ee 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -40,6 +40,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. -- 2.50.1