You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
_curses.window.getch does not check for interruption signals as _curses.window.{getkey,get_wch} do #134210
In _curses.window.{getkey,get_wch}, we are checking for possible interrupting signals and say:
In no-delay mode, an exception is raised if there is no input
However, in getch, we say:
In no-delay mode, -1 is returned if there is no input.
In particular, I think we should also check for signals and possibly raise an exception if PyErr_CheckSignals fails, and otherwise return -1 as documented. (note that getch returns ERR in no-delay mode, see https://linux.die.net/man/3/wgetch).
Another potential issue that I am seeing is a return type mismatch between getch and get_wch or getkey. Both of get_wch() and getkey() returns a PyObject *. Maybe we can change _curses_window_getch_impl to return a PyLong pointer similar to get_wch_impl and getkey_impl? This would make sure we are always dealing with the same return type.
Activity
zydtiger commentedon May 19, 2025
Hi! I think this fix should raise an error when
PyErr_CheckSignals()failed. This is copied from theget_wch()no-delay code:zydtiger commentedon May 19, 2025
Another potential issue that I am seeing is a return type mismatch between
getchandget_wchorgetkey. Both ofget_wch()andgetkey()returns aPyObject *. Maybe we can change_curses_window_getch_implto return aPyLongpointer similar toget_wch_implandgetkey_impl? This would make sure we are always dealing with the same return type.picnixz commentedon May 19, 2025
It's not a mismatch. It's handled by Argument Clinic so it's fine.
picnixz commentedon May 19, 2025
But I'll probably handle it as part of the rest of the cleanup
gh-134210: handle signals in `_curses.window.getch` (#134326)
pythongh-134210: handle signals in `_curses.window.getch` (pythonGH-1…
[3.13] pythongh-134210: handle signals in `_curses.window.getch` (pyt…
gh-134210: refactor signal handling in `_curses.window.{get_wch,getke…
[3.14] gh-134210: handle signals in `_curses.window.getch` (GH-134326) (
[3.13] gh-134210: handle signals in `_curses.window.getch` (GH-134326) (
pythongh-134210: handle signals in `_curses.window.getch` (python#134326
pythongh-134210: refactor signal handling in `_curses.window.{get_wch…
pythongh-134210: handle signals in `_curses.window.getch` (python#134326
pythongh-134210: refactor signal handling in `_curses.window.{get_wch…
pythongh-134210: handle signals in `_curses.window.getch` (python#134326
pythongh-134210: refactor signal handling in `_curses.window.{get_wch…