[New-bugs-announce] [issue37738] curses.addch('a', curses.color_pair(1)) ignores the color information
Marius Gedminas
report at bugs.python.org
Thu Aug 1 09:45:15 EDT 2019
New submission from Marius Gedminas <marius at 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 <report at bugs.python.org>
<https://bugs.python.org/issue37738>
_______________________________________
More information about the New-bugs-announce
mailing list