gh-154840: Keep the color pair out of curses complexchar.attr - #154841
gh-154840: Keep the color pair out of curses complexchar.attr#154841fedonman wants to merge 3 commits into
Conversation
On a wide build getcchar() reports the packed color pair in the attributes, so attr carried it and saturated at 255, although the documentation says the pair is stored separately and is not limited to a color_pair() value. Mask A_COLOR out, as the narrow branch of the same function already does. repr() reads through the same function and is fixed with it.
| self.assertEqual(curses.complexchar('A', 0, 1).pair, 1) | ||
| # attr never carries the color pair, not even a pair that does not fit | ||
| # in a color_pair() value. | ||
| self.assertEqual(curses.complexchar('A', 0, 1).attr, 0) |
There was a problem hiding this comment.
TestCurses.test_complexchar is probably a better place for these new tests.
| PyErr_SetString(state->error, "getcchar() returned ERR"); | ||
| return -1; | ||
| } | ||
| *attr &= ~(attr_t)A_COLOR; |
There was a problem hiding this comment.
Would curses_getcchar() be a better place for the mask?
getcchar() is the one place that reads the pair out of a cell, so the mask belongs there. inch() no longer needs its own. The complexchar checks move to test_complexchar.
|
@serhiy-storchaka Both done, thanks. Moving the mask into The complexchar checks moved to |
complexchar.attrcarried the packed color pair on a wide build and saturated at 255,although the docs say the pair is stored separately and is not limited to a
color_pair()value. Mask
A_COLORin the wide branch ofcurses_cell_attr_pair(), which its narrowbranch already does.
repr()reads through the same function and is fixed with it.The test fails without the change. New in 3.16, so no NEWS entry.