@@ -30,9 +30,8 @@ def initscr():
30
30
fd = _sys .__stdout__ .fileno ())
31
31
stdscr = _curses .initscr ()
32
32
for key , value in _curses .__dict__ .items ():
33
- if key [ 0 : 4 ] == 'ACS_' or key in ('LINES' , 'COLS' ):
33
+ if key . startswith ( 'ACS_' ) or key in ('LINES' , 'COLS' ):
34
34
setattr (curses , key , value )
35
-
36
35
return stdscr
37
36
38
37
# This is a similar wrapper for start_color(), which adds the COLORS and
@@ -41,12 +40,9 @@ def initscr():
41
40
42
41
def start_color ():
43
42
import _curses , curses
44
- retval = _curses .start_color ()
45
- if hasattr (_curses , 'COLORS' ):
46
- curses .COLORS = _curses .COLORS
47
- if hasattr (_curses , 'COLOR_PAIRS' ):
48
- curses .COLOR_PAIRS = _curses .COLOR_PAIRS
49
- return retval
43
+ _curses .start_color ()
44
+ curses .COLORS = _curses .COLORS
45
+ curses .COLOR_PAIRS = _curses .COLOR_PAIRS
50
46
51
47
# Import Python has_key() implementation if _curses doesn't contain has_key()
52
48
@@ -85,10 +81,11 @@ def wrapper(func, /, *args, **kwds):
85
81
# Start color, too. Harmless if the terminal doesn't have
86
82
# color; user can test with has_color() later on. The try/catch
87
83
# works around a minor bit of over-conscientiousness in the curses
88
- # module -- the error return from C start_color() is ignorable.
84
+ # module -- the error return from C start_color() is ignorable,
85
+ # unless they are raised by the interpreter due to other issues.
89
86
try :
90
87
start_color ()
91
- except :
88
+ except _curses . error :
92
89
pass
93
90
94
91
return func (stdscr , * args , ** kwds )
0 commit comments