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
6 changes: 6 additions & 0 deletions Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,12 @@ def test_in_wstr(self):
self.assertEqual(stdscr.in_wstr(0, 0, len(s)), s)
self.assertIsInstance(stdscr.instr(0, 0, len(s)), bytes)

# Reading no characters gives an empty string, like instr() and
# in_wchstr() do. curses does not terminate the buffer in this case.
stdscr.addstr(0, 0, 'abz')
self.assertEqual(stdscr.in_wstr(0, 0, 0), '')
self.assertEqual(stdscr.in_wstr(0), '')

def test_complexchar(self):
# A complexchar is a styled wide-character cell: str() is its text,
# and the attr and pair attributes are its rendition.
Expand Down
2 changes: 1 addition & 1 deletion Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3850,7 +3850,7 @@ PyCursesWindow_in_wstr(PyObject *op, PyObject *args)
}

n = Py_MIN(n, max_buf_size - 1);
wchar_t *buf = PyMem_New(wchar_t, n + 1);
wchar_t *buf = PyMem_Calloc(n + 1, sizeof(wchar_t));
if (buf == NULL) {
return PyErr_NoMemory();
}
Expand Down
Loading