Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,14 @@ def test_complexchar(self):
self.assertEqual(str(cc), 'z')
self.assertEqual(cc.attr, 0)
self.assertEqual(cc.pair, 0)
# 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)
self.assertEqual(curses.complexchar('A', 0, 300).attr, 0)
self.assertEqual(curses.complexchar('A', curses.A_BOLD, 1).attr,
curses.A_BOLD)
self.assertEqual(curses.complexchar('A', 0, 1).pair, 1)
self.assertEqual(curses.complexchar('A', 0, 300).pair, 300)
# Immutable rendition.
self.assertRaises(AttributeError, setattr, cc, 'attr', 1)
self.assertRaises(AttributeError, setattr, cc, 'pair', 1)
Expand Down Expand Up @@ -592,7 +600,7 @@ def test_in_wch_color(self):
stdscr.addch(0, 0, curses.complexchar('A', curses.A_BOLD, 1))
cc = stdscr.in_wch(0, 0)
self.assertEqual(str(cc), 'A')
self.assertTrue(cc.attr & curses.A_BOLD)
self.assertEqual(cc.attr, curses.A_BOLD)
self.assertEqual(cc.pair, 1)
self.assertEqual(curses.complexchar('A', 0, 1).pair, 1)

Expand Down
5 changes: 4 additions & 1 deletion Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,9 @@ curses_getcchar(const cchar_t *wcval, wchar_t *wstr, attr_t *attrs, int *pair)
*pair = spair;
}
#endif
if (rtn != ERR) {
*attrs &= ~(attr_t)A_COLOR;
}
return rtn;
}

Expand Down Expand Up @@ -3674,7 +3677,7 @@ _curses_window_inch_impl(PyCursesWindowObject *self, int group_right_1,
byte = 0;
}
}
rtn = (chtype)byte | (attrs & ~(attr_t)A_COLOR) | COLOR_PAIR(pair);
rtn = (chtype)byte | attrs | COLOR_PAIR(pair);
#else
if (!group_right_1) {
rtn = winch(self->win);
Expand Down
Loading