@@ -30,9 +30,8 @@ def initscr():
3030              fd = _sys .__stdout__ .fileno ())
3131    stdscr  =  _curses .initscr ()
3232    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' ):
3434            setattr (curses , key , value )
35- 
3635    return  stdscr 
3736
3837# This is a similar wrapper for start_color(), which adds the COLORS and 
@@ -41,12 +40,9 @@ def initscr():
4140
4241def  start_color ():
4342    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 
5046
5147# Import Python has_key() implementation if _curses doesn't contain has_key() 
5248
@@ -85,10 +81,11 @@ def wrapper(func, /, *args, **kwds):
8581        # Start color, too.  Harmless if the terminal doesn't have 
8682        # color; user can test with has_color() later on.  The try/catch 
8783        # 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. 
8986        try :
9087            start_color ()
91-         except :
88+         except   _curses . error :
9289            pass 
9390
9491        return  func (stdscr , * args , ** kwds )
0 commit comments