FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-155499: Allow zero defaults with wide curses borders by ahmedtaha100 · Pull Request #155523 · python/cpython · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .py  (1) .rst  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 4 additions & 0 deletions Lib/test/test_curses.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ def test_wide_characters(self):
if self._encodable(vline + hline):
stdscr.border(vline, vline, hline, hline)
stdscr.box(vline, hline)
# Zero still requests the default character in the wide path.
stdscr.border('|', '|', '-', '-', 0, 0, 0, 0)
stdscr.box('|', 0)
stdscr.box(0, '-')
# border() and box() cannot mix integer and wide-string characters.
self.assertRaises(TypeError, stdscr.box, vline, ord('-'))

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix :meth:`~curses.window.border` and :meth:`~curses.window.box` to accept the
documented ``0`` default character alongside strings.
8 changes: 5 additions & 3 deletions Modules/_cursesmodule.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2705,7 +2705,7 @@ _curses_window_border_impl(PyCursesWindowObject *self, PyObject *ls,
}
if (use_wide) {
for (i = 0; i < 8; i++) {
if (objs[i] == NULL) {
if (objs[i] == NULL || (types[i] == 1 && ch[i] == 0)) {
wch_p[i] = NULL; /* use the default character */
}
else if (types[i] == 2) {
Expand Down Expand Up @@ -2775,13 +2775,15 @@ _curses_window_box_impl(PyCursesWindowObject *self, int group_right_1,
}
}
if (t1 == 2 || t2 == 2) {
if (t1 != 2 || t2 != 2) {
if ((t1 != 2 && ch1 != 0) || (t2 != 2 && ch2 != 0)) {
PyErr_SetString(PyExc_TypeError,
"box() cannot mix integer or bytes characters "
"with wide string characters");
return NULL;
}
int rtn = wborder_set(self->win, &wch1, &wch1, &wch2, &wch2,
const cchar_t *wch1_p = t1 == 2 ? &wch1 : NULL;
const cchar_t *wch2_p = t2 == 2 ? &wch2 : NULL;
int rtn = wborder_set(self->win, wch1_p, wch1_p, wch2_p, wch2_p,
NULL, NULL, NULL, NULL);
return curses_window_check_err(self, rtn, "wborder_set", "box");
}
Expand Down
Loading

Back | FazBrowse Home | New Git URL