Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Description
Bug report
Bug description:
This issue is motivated by adiscussion with@serhiy-storchaka on#122456. Pyrepl/code.InteractiveInterpreter
does not handle exceptions at various points, see the linked commend for an example.
Directly after writing this, I also got the following traceback that I now can't reproduce, by pressing ctrl-r then searching for a string, and then pressing ctrl-c at somehow the wrong point:
>>>Traceback (mostrecentcalllast):File"/home/cfbolz/projects/cpython/Lib/_pyrepl/simple_interact.py",line147,inrun_multiline_interactive_consolestatement=multiline_input(more_lines,ps1,ps2)File"/home/cfbolz/projects/cpython/Lib/_pyrepl/readline.py",line385,inmultiline_inputreturnreader.readline()~~~~~~~~~~~~~~~^^File"/home/cfbolz/projects/cpython/Lib/_pyrepl/reader.py",line773,inreadlineself.handle1()~~~~~~~~~~~~^^File"/home/cfbolz/projects/cpython/Lib/_pyrepl/reader.py",line730,inhandle1event=self.console.get_event(block)File"/home/cfbolz/projects/cpython/Lib/_pyrepl/unix_console.py",line391,inget_eventself.push_char(self.__read(1))~~~~~~~~~~~^^^File"/home/cfbolz/projects/cpython/Lib/_pyrepl/unix_console.py",line203,in__readself.input_buffer=os.read(self.input_fd,10000)~~~~~~~^^^^^^^^^^^^^^^^^^^^^^KeyboardInterruptDuringhandlingoftheaboveexception,anotherexceptionoccurred:Traceback (mostrecentcalllast):File"<frozen runpy>",line198,in_run_module_as_mainFile"<frozen runpy>",line88,in_run_codeFile"/home/cfbolz/projects/cpython/Lib/_pyrepl/__main__.py",line6,in<module>__pyrepl_interactive_console()~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^File"/home/cfbolz/projects/cpython/Lib/_pyrepl/main.py",line59,ininteractive_consolerun_multiline_interactive_console(console)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^File"/home/cfbolz/projects/cpython/Lib/_pyrepl/simple_interact.py",line164,inrun_multiline_interactive_consoler.pop_input_trans()~~~~~~~~~~~~~~~~~^^File"/home/cfbolz/projects/cpython/Lib/_pyrepl/reader.py",line546,inpop_input_transself.input_trans=self.input_trans_stack.pop()~~~~~~~~~~~~~~~~~~~~~~~~~~^^IndexError:popfromemptylist
This crashed pyrepl. I think it would be better if we printed the exception, but then actually stayed in pyrepl, to make sure we don't lose the repl state which might have been annoying to get to.
Another way to crash pyrepl, but not the classic repl is to closesys.stderr
and then raising an exception.
We could make pyrepl less crash-prone that by adding anexcept BaseException
around the pyrepl loop inrun_multiline_interactive_console
.
Any opinions,@pablogsal,@ambv?
CPython versions tested on:
3.13, CPython main branch
Operating systems tested on:
Linux