Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5fb05ea

Browse files
authored
[3.13]gh-134210: handle signals in_curses.window.getch (GH-134326) (#134784)
(cherry picked from commit51762b6)
1 parenta5f281f commit5fb05ea

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:func:`curses.window.getch` now correctly handles signals. Patch by Bénédikt
2+
Tran.

‎Modules/_cursesmodule.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ _curses_window_getbkgd_impl(PyCursesWindowObject *self)
13851385
}
13861386

13871387
/*[clinic input]
1388-
_curses.window.getch -> int
1388+
_curses.window.getch
13891389
13901390
[
13911391
y: int
@@ -1402,10 +1402,10 @@ keypad keys and so on return numbers higher than 256. In no-delay mode, -1
14021402
is returned if there is no input, else getch() waits until a key is pressed.
14031403
[clinic start generated code]*/
14041404

1405-
staticint
1405+
staticPyObject*
14061406
_curses_window_getch_impl(PyCursesWindowObject*self,intgroup_right_1,
14071407
inty,intx)
1408-
/*[clinic end generated code: output=980aa6af0c0ca387 input=bb24ebfb379f991f]*/
1408+
/*[clinic end generated code: output=e1639e87d545e676 input=73f350336b1ee8c8]*/
14091409
{
14101410
intrtn;
14111411

@@ -1418,7 +1418,17 @@ _curses_window_getch_impl(PyCursesWindowObject *self, int group_right_1,
14181418
}
14191419
Py_END_ALLOW_THREADS
14201420

1421-
returnrtn;
1421+
if (rtn==ERR) {
1422+
// We suppress ERR returned by wgetch() in nodelay mode
1423+
// after we handled possible interruption signals.
1424+
if (PyErr_CheckSignals()) {
1425+
returnNULL;
1426+
}
1427+
// ERR is an implementation detail, so to be on the safe side,
1428+
// we forcibly set the return value to -1 as documented above.
1429+
rtn=-1;
1430+
}
1431+
returnPyLong_FromLong(rtn);
14221432
}
14231433

14241434
/*[clinic input]

‎Modules/clinic/_cursesmodule.c.h

Lines changed: 3 additions & 8 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp