GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Exact reporting of `curses` C function failures · Issue #133579 · python/cpython

Exact reporting of curses C function failures #133579

New issue
Copy link
New issue
Copy link
Closed
Closed
Exact reporting of curses C function failures#133579
Copy link
Assignees
picnixz
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@picnixz
picnixz
opened on May 7, 2025
Issue body actions

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

  • gh-133579: consistently report C curses function failures #134327
  • gh-133579: correctly report C curses errors in _curses_panel #134629
Reacted by Petr Viktorin

Activity

  1. picnixz
    self-assigned this
    on May 7, 2025
  2. picnixz
    added
    type-featureA feature request or enhancementA feature request or enhancement
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    on May 7, 2025
  3. picnixz
    added this to Curses issueson May 7, 2025
  4. encukou commented on May 17, 2025

    @encukou
    encukou
    on May 17, 2025
    Member
    More actions

    What should we do for a failing delwin() in the destructor?

    Set an exception and call PyErr_WriteUnraisable, so that it's caught by unraisablehook.

    What should we do for wattrset() when this routine is not the "important" one?

    In _curses_window_addstr_impl, wattrset is only called if the user explicitly called addstr with an attr argument. Failure to set them should be a hard error, to be handled by the user.

    _curses_window_box_impl

    IMO, if an error is reported, something is wrong and we should raise an exception.


    IMO, these would be bugfixes, but should not be backported.

    Reacted by Bénédikt Tran
  5. picnixz
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    triagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.
    and removed
    type-featureA feature request or enhancementA feature request or enhancement
    triagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.
    on May 18, 2025
  6. picnixz commented on May 18, 2025

    @picnixz
    picnixz
    on May 18, 2025
    MemberAuthor
    More actions

    Thanks. I've found other occurrences where curses C functions are called but the error handling is not done. It's just that it was sometimes under ifdef that I missed. I need #125844 to be merged first so that I can use the helpers out there so I'm holding this work for now.

  7. picnixz commented on May 19, 2025

    @picnixz
    picnixz
    on May 19, 2025
    MemberAuthor
    More actions

    On failure, _curses.window.getstr also return an empty string instead of reporting the error. It may be fine, but I don't know if it wouldn't be better to actually report the possible error.

  8. picnixz
    added a commit that references this issue on May 27, 2025

    gh-133579: consistently report C curses function failures (#134327)

    30dde1e
  9. picnixz
    added a commit that references this issue on Jun 8, 2025

    gh-133579: correctly report C curses errors in `_curses_panel` (#134629)

    d610f11
  10. picnixz
    closed this as completedon Jun 8, 2025
  11. github-project-automation
    moved this to Done in Curses issueson Jun 8, 2025
  12. lkollar
    added a commit that references this issue on Jun 19, 2025

    pythongh-133579: correctly report C curses errors in `_curses_panel` (p…

    9171a96
  13. Pranjal095
    added 2 commits that reference this issue on Jul 12, 2025

    pythongh-133579: consistently report C curses function failures (pyth…

    1a7b413

    pythongh-133579: correctly report C curses errors in `_curses_panel` (p…

    f4277e3
  14. taegyunkim
    added 2 commits that reference this issue on Aug 4, 2025

    pythongh-133579: consistently report C curses function failures (pyth…

    770a3bf

    pythongh-133579: correctly report C curses errors in `_curses_panel` (p…

    bf1c3fa
  15. Agent-Hellboy
    added a commit that references this issue on Aug 19, 2025

    pythongh-133579: correctly report C curses errors in `_curses_panel` (p…

    40b40ad
  16. gostak-dd
    added a commit that references this issue on Jun 2, 2026

    pythongh-133579: consistently report C curses function failures (pyth…

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

Metadata

Metadata

Assignees

  • @picnixz
    picnixz

Labels

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

Projects

  • Curses issues
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.