Skip to content

Exact reporting of curses C function failures #133579

Closed
@picnixz

Description

@picnixz

When calling some curses C functions, we ignore their return values. Those are:

  • in PyCursesWindow_dealloc, we ignore delwin() errors

  • in _curses_initscr_impl, we ignore wrefresh() errors

  • in _curses_window_addstr_impl, we ignore wattrset() errors and prefer reporting errors due to adding strings. Same for the insstr* functions

  • in _curses_window_box_impl, we ignore the error returned by box(). This is correct because the manual says (for box):

    All routines return the integer OK. The SVr4.0 manual says "or a non-negative integer if immedok is set", but this appears to be an error. X/Open does not define any error conditions. This implementation returns an error if the window pointer is null.

    In this case, I think it's better to explicitly suppress the return value and link the manpage.

The question now is:

  • What should we do for a failing delwin() in the destructor?
  • What should we do for wattrset() when this routine is not the "important" one?

cc @encukou


Note

We will not backport these fixes as they could break existing code that could be surprised by a new exception.

Linked PRs

Metadata

Metadata

Assignees

Labels

extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions