Skip to content

Commit 019c839

Browse files
committed
[lldb] Fix PExpectTest when using utf-8 as the encoding
PExpect 4.6, when using 'utf-8' throws a TypeError when trying to write to the log file: File "llvm-project/lldb/third_party/Python/module/pexpect-4.6/pexpect/spawnbase.py", line 126, in _log self.logfile.write(s) TypeError: a bytes-like object is required, not 'str' This looks like a bug in PExpect to me. Since the log file is only used for tracing, work around the issue by disabling the log file when specifying an encoding. This should fix the Debian bot [1] which runs the test with tracing enabled (-t). [1] https://lab.llvm.org/buildbot/#/builders/68/builds/59955
1 parent 45c1605 commit 019c839

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lldb/packages/Python/lldbsuite/test/lldbpexpect.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ def launch(
2929
encoding=None,
3030
use_colors=False,
3131
):
32-
logfile = getattr(sys.stdout, "buffer", sys.stdout) if self.TraceOn() else None
32+
# Using a log file is incompatible with using utf-8 as the encoding.
33+
logfile = (
34+
getattr(sys.stdout, "buffer", sys.stdout)
35+
if (self.TraceOn() and not encoding)
36+
else None
37+
)
3338

3439
args = []
3540
if run_under is not None:

0 commit comments

Comments
 (0)