diff --git a/Doc/library/msvcrt.rst b/Doc/library/msvcrt.rst index f4a1125554a051..22a63ae8eaae49 100644 --- a/Doc/library/msvcrt.rst +++ b/Doc/library/msvcrt.rst @@ -114,7 +114,9 @@ Console I/O is not already available, but will not wait for :kbd:`Enter` to be pressed. If the pressed key was a special function key, this will return ``'\000'`` or ``'\xe0'``; the next call will return the keycode. - The :kbd:`Control-C` keypress cannot be read with this function. + When pressed while this function is waiting for input, :kbd:`Control-C` + can be read as ``b'\x03'`` without invoking the :const:`signal.SIGINT` + handler. .. function:: getwch() diff --git a/PC/clinic/msvcrtmodule.c.h b/PC/clinic/msvcrtmodule.c.h index 7a43daa987b206..e4e5157050f088 100644 --- a/PC/clinic/msvcrtmodule.c.h +++ b/PC/clinic/msvcrtmodule.c.h @@ -236,8 +236,9 @@ PyDoc_STRVAR(msvcrt_getch__doc__, "Nothing is echoed to the console. This call will block if a keypress is\n" "not already available, but will not wait for Enter to be pressed. If the\n" "pressed key was a special function key, this will return \'\\000\' or\n" -"\'\\xe0\'; the next call will return the keycode. The Control-C keypress\n" -"cannot be read with this function."); +"\'\\xe0\'; the next call will return the keycode.\n" +"When pressed while this function is waiting for input, Control-C can be\n" +"read as b\'\\x03\' without invoking the signal.SIGINT handler."); #define MSVCRT_GETCH_METHODDEF \ {"getch", (PyCFunction)msvcrt_getch, METH_NOARGS, msvcrt_getch__doc__}, @@ -743,4 +744,4 @@ msvcrt_SetErrorMode(PyObject *module, PyObject *arg) #ifndef MSVCRT_GETERRORMODE_METHODDEF #define MSVCRT_GETERRORMODE_METHODDEF #endif /* !defined(MSVCRT_GETERRORMODE_METHODDEF) */ -/*[clinic end generated code: output=58c1771c8b9a209b input=a9049054013a1b77]*/ +/*[clinic end generated code: output=db004ea2187c98cc input=a9049054013a1b77]*/ diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c index 868650dd31d9a1..e6beb14e8f2259 100644 --- a/PC/msvcrtmodule.c +++ b/PC/msvcrtmodule.c @@ -227,13 +227,14 @@ Read a keypress and return the resulting character as a byte string. Nothing is echoed to the console. This call will block if a keypress is not already available, but will not wait for Enter to be pressed. If the pressed key was a special function key, this will return '\000' or -'\xe0'; the next call will return the keycode. The Control-C keypress -cannot be read with this function. +'\xe0'; the next call will return the keycode. +When pressed while this function is waiting for input, Control-C can be +read as b'\x03' without invoking the signal.SIGINT handler. [clinic start generated code]*/ static int msvcrt_getch_impl(PyObject *module) -/*[clinic end generated code: output=a4e51f0565064a7d input=37a40cf0ed0d1153]*/ +/*[clinic end generated code: output=a4e51f0565064a7d input=5c91f51ac2355241]*/ { int ch;