Skip to content

Commit 4138f24

Browse files
committed
Document a workaround for a curses bug
The ncurses library has a bug which can provoke a segfault when a window is resized. The bug is provoked when a string with embedded newlines is added via addstr(). This commit documents that problem in the curses python library documentation and relates how to workaround the problem in the calling code. Related to https://bugs.python.org/issue35924
1 parent 3988986 commit 4138f24

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Doc/library/curses.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,16 @@ the following methods and attributes:
708708

709709
.. note::
710710

711-
Writing outside the window, subwindow, or pad raises :exc:`curses.error`.
712-
Attempting to write to the lower right corner of a window, subwindow,
713-
or pad will cause an exception to be raised after the string is printed.
711+
* Writing outside the window, subwindow, or pad raises :exc:`curses.error`.
712+
Attempting to write to the lower right corner of a window, subwindow,
713+
or pad will cause an exception to be raised after the string is printed.
714+
715+
* A `bug in ncurses <https://bugs.python.org/issue35924>`_, the backend
716+
for this Python module, can cause SegFaults when resizing windows. This
717+
is fixed in ncurses-6.1-20190511. If you are stuck with an earlier
718+
ncurses, you can avoid triggering this if you do not call :func:`addstr`
719+
with a *str* that has embedded newlines. Instead, call :func:`addstr`
720+
separately for each line.
714721

715722

716723
.. method:: window.attroff(attr)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add a note to the ``curses.addstr()`` documentation to warn that multiline
2+
strings can cause segfaults because of an ncurses bug.

0 commit comments

Comments
 (0)