Skip to content

gh-157140: Correct five curses documentation statements - #157141

Open
fedonman wants to merge 4 commits into
python:mainfrom
fedonman:fix-curses-doc-contradictions
Open

fedonman wants to merge 4 commits into
python:mainfrom
fedonman:fix-curses-doc-contradictions

Conversation

@fedonman

@fedonman fedonman commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Five statements in Doc/library/curses.rst describe behaviour the module does not have: halfdelay() does not make getch() raise on timeout, termname() is not truncated to 14 characters, window.scroll() raises curses.error rather than doing nothing without scrollok(), window.insnstr() inserts nothing for n == 0, and the window.insch(y, x, ch) form moves the cursor. Each was measured on a pty; the insch and insnstr wording now matches insstr, which already gets it right.

halfdelay() does not raise on timeout, getch() returns -1; termname()
is not truncated to 14 characters; scroll() raises curses.error rather
than doing nothing without scrollok(); insnstr() inserts nothing for
n == 0, not the whole string; and insch(y, x, ch) moves the cursor.
@read-the-docs-community

read-the-docs-community Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. There are inaccuracies for halfdelay() and termname(), all other looks fine.

Please try to avoid reflow to minimize the diff. If this is unavoidable, prefer to use semantic line breaks (break paragraph between sentences) -- this can minimize future diffs.

Comment thread Doc/library/curses.rst Outdated
blocking for *tenths* tenths of seconds, raise an exception if nothing has
been typed. The value of *tenths* must be a number between ``1`` and ``255``. Use
:func:`nocbreak` to leave half-delay mode.
blocking for *tenths* tenths of seconds, :meth:`~window.getch` returns ``-1``

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old sentence was not wrong for every reader -- on a timeout get_wch() and getkey() do raise an exception, and only getch() returns -1. Please mention both.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

Comment thread Doc/library/curses.rst Outdated

Return the value of the environment variable :envvar:`TERM`, as a bytes object,
truncated to 14 characters.
Return the value of the environment variable :envvar:`TERM`, as a bytes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Some curses libraries truncate it to 14 characters.
  2. It is not just the value of the environment variable TERM, it is the name passed to setupterm() etc (according to the X/Open curses specification).
   Return the name of the terminal in use, as a bytes object.
   This is the name passed to :func:`initscr`, :func:`newterm` or
   :func:`setupterm`, or the value of the :envvar:`TERM` environment variable
   if none was given.  Some curses libraries truncate it to 14 characters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, applied your wording.

Comment thread Doc/library/curses.rst
halfdelay() now says that getkey() and get_wch() raise while getch()
returns -1; termname() describes the name of the terminal in use rather
than TERM alone, and keeps the 14-character note as a library-dependent
caveat; the touched paragraphs use semantic line breaks so that no line
is reflowed needlessly.
Comment thread Doc/library/curses.rst Outdated
Return the value of the environment variable :envvar:`TERM`, as a bytes object,
truncated to 14 characters.
Return the name of the terminal in use, as a bytes object.
This is the name passed to :func:`initscr`, :func:`newterm` or

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, initscr() take no terminal name. Drop it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants