New submission from Marius Gedminas <>:

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.init_pair(1, curses.COLOR_RED, -1)                                   
    curses.init_pair(2, curses.COLOR_GREEN, -1)                                 
    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)                
### 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 <>
Python-bugs-list mailing list

Reply via email to