diff options
| author | Jonas Devlieghere <jonas@devlieghere.com> | 2020-06-16 11:02:00 -0700 |
|---|---|---|
| committer | Jonas Devlieghere <jonas@devlieghere.com> | 2020-06-16 11:05:19 -0700 |
| commit | 4dd3dfe8e3266459d855008af78d611071ff99e2 (patch) | |
| tree | a87c48fd68260e395bdb1c7d2d0100fd30f28a1d /lldb/test/Shell/ScriptInterpreter/Python | |
| parent | ed67f5e7ab59d378bb09153a0df132333c43c9cb (diff) | |
| download | llvm-4dd3dfe8e3266459d855008af78d611071ff99e2.zip llvm-4dd3dfe8e3266459d855008af78d611071ff99e2.tar.gz llvm-4dd3dfe8e3266459d855008af78d611071ff99e2.tar.bz2 | |
[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
Diffstat (limited to 'lldb/test/Shell/ScriptInterpreter/Python')
| -rw-r--r-- | lldb/test/Shell/ScriptInterpreter/Python/eof.test | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/eof.test b/lldb/test/Shell/ScriptInterpreter/Python/eof.test new file mode 100644 index 0000000..d777f24 --- /dev/null +++ b/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: >>> |
