-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Exact reporting of curses
C function failures
#133579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Set an exception and call
In
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. |
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. |
On failure, |
Some curses module-level functions and window methods now raise a `curses.error` when a call to a C curses function fails: - Module-level functions: assume_default_colors, baudrate, cbreak, echo, longname, initscr, nl, raw, termattrs, termname, and unctrl. - Window methods: addch, addnstr, addstr, border, box, chgat, getbkgd, inch, insstr, and insnstr. In addition, `curses.window.refresh` and `curses.window.noutrefresh` now raise a `TypeError` instead of a `curses.error` when called with an incorrect number of arguments for pads. See also ee36db5 for similar changes.
Uh oh!
There was an error while loading. Please reload this page.
When calling some curses C functions, we ignore their return values. Those are:
in
PyCursesWindow_dealloc
, we ignoredelwin()
errorsin
_curses_initscr_impl
, we ignorewrefresh()
errorsin
_curses_window_addstr_impl
, we ignorewattrset()
errors and prefer reporting errors due to adding strings. Same for theinsstr*
functionsin
_curses_window_box_impl
, we ignore the error returned bybox()
. This is correct because the manual says (forbox
):In this case, I think it's better to explicitly suppress the return value and link the manpage.
The question now is:
delwin()
in the destructor?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
_curses_panel
#134629The text was updated successfully, but these errors were encountered: