Skip to content

Commit ffd7cf0

Browse files
committed
gh-159072: Clarify Ctrl+C and SIGINT handler behavior
1 parent 32f63f5 commit ffd7cf0

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎Doc/library/msvcrt.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ Console I/O
114114
is not already available, but will not wait for :kbd:`Enter` to be
115115
pressed. If the pressed key was a special function key, this will
116116
return ``'\000'`` or ``'\xe0'``; the next call will return the keycode.
117+
When pressed while this function is waiting for input, :kbd:`Control-C`
118+
can be read as ``b'\x03'`` without invoking the :const:`signal.SIGINT`
119+
handler.
117120

118121

119122
.. function:: getwch()

‎PC/clinic/msvcrtmodule.c.h‎

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎PC/msvcrtmodule.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,13 @@ Nothing is echoed to the console. This call will block if a keypress is
228228
not already available, but will not wait for Enter to be pressed. If the
229229
pressed key was a special function key, this will return '\000' or
230230
'\xe0'; the next call will return the keycode.
231+
When pressed while this function is waiting for input, Control-C can be
232+
read as b'\x03' without invoking the signal.SIGINT handler.
231233
[clinic start generated code]*/
232234

233235
static int
234236
msvcrt_getch_impl(PyObject *module)
235-
/*[clinic end generated code: output=a4e51f0565064a7d input=967463215ff3ab9d]*/
237+
/*[clinic end generated code: output=a4e51f0565064a7d input=5c91f51ac2355241]*/
236238
{
237239
int ch;
238240

0 commit comments

Comments
 (0)