This revision was automatically updated to reflect the committed changes. Closed by commit rG4dd3dfe8e326: [lldb/Python] Fix the infinitely looping Python prompt bug (authored by JDevlieghere). Herald added a project: LLDB.
Changed prior to commit: https://reviews.llvm.org/D81898?vs=270924&id=271147#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81898/new/ https://reviews.llvm.org/D81898 Files: lldb/source/Interpreter/embedded_interpreter.py lldb/test/Shell/ScriptInterpreter/Python/eof.test Index: lldb/test/Shell/ScriptInterpreter/Python/eof.test =================================================================== --- /dev/null +++ lldb/test/Shell/ScriptInterpreter/Python/eof.test @@ -0,0 +1,6 @@ +RUN: echo 'foo' | %lldb -o script | FileCheck %s + +# Check that the python interpreter detects the OF and the prompt is printed +# exactly once. +CHECK: >>> +CHECK-NOT: >>> Index: lldb/source/Interpreter/embedded_interpreter.py =================================================================== --- lldb/source/Interpreter/embedded_interpreter.py +++ lldb/source/Interpreter/embedded_interpreter.py @@ -73,7 +73,12 @@ def readfunc_stdio(prompt): sys.stdout.write(prompt) sys.stdout.flush() - return sys.stdin.readline().rstrip() + line = sys.stdin.readline() + # Readline always includes a trailing newline character unless the file + # ends with an incomplete line. An empty line indicates EOF. + if not line: + raise EOFError + return line.rstrip() def run_python_interpreter(local_dict):
Index: lldb/test/Shell/ScriptInterpreter/Python/eof.test =================================================================== --- /dev/null +++ lldb/test/Shell/ScriptInterpreter/Python/eof.test @@ -0,0 +1,6 @@ +RUN: echo 'foo' | %lldb -o script | FileCheck %s + +# Check that the python interpreter detects the OF and the prompt is printed +# exactly once. +CHECK: >>> +CHECK-NOT: >>> Index: lldb/source/Interpreter/embedded_interpreter.py =================================================================== --- lldb/source/Interpreter/embedded_interpreter.py +++ lldb/source/Interpreter/embedded_interpreter.py @@ -73,7 +73,12 @@ def readfunc_stdio(prompt): sys.stdout.write(prompt) sys.stdout.flush() - return sys.stdin.readline().rstrip() + line = sys.stdin.readline() + # Readline always includes a trailing newline character unless the file + # ends with an incomplete line. An empty line indicates EOF. + if not line: + raise EOFError + return line.rstrip() def run_python_interpreter(local_dict):
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits