Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d285318

Browse files
committed
Issue #5622: Fix curses.wrapper to raise correct exception if curses
initialization fails.
1 parent c8ab6ee commit d285318

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

Lib/curses/wrapper.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def wrapper(func, *args, **kwds):
4343
return func(stdscr, *args, **kwds)
4444
finally:
4545
# Set everything back to normal
46-
stdscr.keypad(0)
47-
curses.echo()
48-
curses.nocbreak()
49-
curses.endwin()
46+
if 'stdscr' in locals():
47+
stdscr.keypad(0)
48+
curses.echo()
49+
curses.nocbreak()
50+
curses.endwin()

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Core and Builtins
3737
Library
3838
-------
3939

40+
- Issue #5622: Fix curses.wrapper to raise correct exception if curses
41+
initialization fails.
42+
4043
- Issue #11391: Writing to a mmap object created with
4144
``mmap.PROT_READ|mmap.PROT_EXEC`` would segfault instead of raising a
4245
TypeError. Patch by Charles-François Natali.

0 commit comments

Comments
 (0)