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

make pyrepl more robust against crashes #122468

Open
Labels
topic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error
@cfbolz

Description

@cfbolz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp