New submission from Marius Gedminas <mar...@gedmin.as>:

curses.addch() ignores color information if I pass it a string of length one.  
Color works fine if I pass it a byte string or an int.  Here's a reproducer:

### start of example ###
import curses                                                                   
                                                            
                                                                                
                                                            
                                                                                
                                                            
def main(stdscr):                                                               
                                                            
    curses.start_color()                                                        
                                                            
    curses.use_default_colors()                                                 
                                                            
    curses.init_pair(1, curses.COLOR_RED, -1)                                   
                                                            
    curses.init_pair(2, curses.COLOR_GREEN, -1)                                 
                                                            
    curses.curs_set(0)                                                          
                                                            
                                                                                
                                                            
    stdscr.addch("a", curses.color_pair(1))                                     
                                                            
    stdscr.addch("b", curses.color_pair(2) | curses.A_BOLD)                     
                                                            
    stdscr.addch(b"c", curses.color_pair(1))                                    
                                                            
    stdscr.addch(b"d", curses.color_pair(2) | curses.A_BOLD)                    
                                                            
    stdscr.addch(ord("e"), curses.color_pair(1))                                
                                                            
    stdscr.addch(ord("f"), curses.color_pair(2) | curses.A_BOLD)                
                                                            
    stdscr.refresh()                                                            
                                                            
                                                                                
                                                            
    stdscr.getch()                                                              
                                                            
                                                                                
                                                            
                                                                                
                                                            
curses.wrapper(main)                                                            
                                                            
### end of example ###

On Python 2.7 this prints 'abcdef' in alternating red and green.  On Python 3.5 
through 3.8 this prints 'ab' in white and the rest in red/green.

Note that only color pair information is lost -- the bold attribute is 
correctly set on the 'b'.

----------
components: Library (Lib)
messages: 348855
nosy: mgedmin
priority: normal
severity: normal
status: open
title: curses.addch('a', curses.color_pair(1)) ignores the color information
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37738>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to