serhiy-storchaka · GitHub

Bug report

Some curses methods silently truncate a color pair or attributes that do not fit in a chtype, turning a range error into a wrong-rendering bug instead of an exception:

  • curses.color_pair(n) masks n into the chtype's ~8-bit color field, so a pair ≥ 256 wraps to a lower pair and shows the wrong colors with no error (Ncurses Extended Color Pairs incorrectly display as copies of lower 256 color pairs #119138).
  • addch, addstr, addnstr, insch, insstr, insnstr, bkgd, bkgdset, echochar, hline, vline, box, border, attron, attroff, attrset and slk_attron/slk_attroff/slk_attrset take a raw long attr and narrow anything outside 0 .. 0xFFFFFFFF.

This is inconsistent with the rest of the module, which already raises rather than truncating: pair_converter (pair > INT_MAX/COLOR_PAIRS-1), component_converter (RGB outside 0..1000), attr_converter (gh-152219, value > (attr_t)-1) and curses_setcchar (pair beyond a short).

Linked PRs

Read the original on github.com ↗