Skip to content

Commit 794d8fe

Browse files
committed
pythongh-134644: handle exceptions set in PyOS_Readline
The builtin input calls `PyOS_Readline` but seems to assume it does not set exceptions: if the call fails it checks signals and runs handlers if any are pending, which will cause an assertion failure if an exception has already been set. Fix this by only checking signals if an exception has not already been set.
1 parent 2fd09b0 commit 794d8fe

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Python/bltinmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2426,7 +2426,8 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
24262426
}
24272427
s = PyOS_Readline(stdin, stdout, promptstr);
24282428
if (s == NULL) {
2429-
PyErr_CheckSignals();
2429+
if (!PyErr_Occurred())
2430+
PyErr_CheckSignals();
24302431
if (!PyErr_Occurred())
24312432
PyErr_SetNone(PyExc_KeyboardInterrupt);
24322433
goto _readline_errors;

0 commit comments

Comments
 (0)