[all-commits] [llvm/llvm-project] 4dd3df: [lldb/Python] Fix the infinitely looping Python pr...

Jonas Devlieghere via All-commits all-commits at lists.llvm.org
Tue Jun 16 11:05:57 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 4dd3dfe8e3266459d855008af78d611071ff99e2
      https://github.com/llvm/llvm-project/commit/4dd3dfe8e3266459d855008af78d611071ff99e2
  Author: Jonas Devlieghere <jonas at devlieghere.com>
  Date:   2020-06-16 (Tue, 16 Jun 2020)

  Changed paths:
    M lldb/source/Interpreter/embedded_interpreter.py
    A lldb/test/Shell/ScriptInterpreter/Python/eof.test

  Log Message:
  -----------
  [lldb/Python] Fix the infinitely looping Python prompt bug

Executing commands below will get you bombarded by a wall of Python
command prompts (>>> ).

$ echo 'foo' | ./bin/lldb -o script
$ cat /tmp/script
script
print("foo")
$ lldb --source /tmp/script

The issue is that our custom input reader doesn't handle EOF. According
to the Python documentation, file.readline always includes a trailing
newline character unless the file ends with an incomplete line. An empty
string signals EOF. This patch raises an EOFError when that happens.

[1] https://docs.python.org/2/library/stdtypes.html#file.readline

Differential revision: https://reviews.llvm.org/D81898




More information about the All-commits mailing list