[Lldb-commits] [PATCH] D76955: [lldb/Test] Decode stdout and stderr in case it contains UTF-8

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Mar 30 01:35:29 PDT 2020


labath added a comment.

In D76955#1947160 <https://reviews.llvm.org/D76955#1947160>, @JDevlieghere wrote:

> Right, I didn't check whether out and err were strings or bytes. I'll see if I can find a better solution or alternatively wrap it in a try-except.


It might be simplest to wrap that in `if PY2` (when can we drop python2 support again?). I don't believe this can happen with py3 due to the try-catch here <https://github.com/llvm/llvm-project/blob/master/llvm/utils/lit/lit/util.py#L82>.

A lot of this stuff could be cleaned up when python2 is gone. Right now it's very confusing to reason about what is the type a thing in which python version.



================
Comment at: lldb/test/API/lldbtest.py:85
                     'import sys; print(sys.executable)'
-                ]).decode('utf-8').strip()
+                ]).decode('utf-8', errors='ignore').strip()
                 shutil.copy(python, copied_python)
----------------
`replace` or `backslashreplace` [[ https://docs.python.org/3/howto/unicode.html#the-string-type | error ]] strategy might be better, so that the presence/value of the erroneous character is not completely lost.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76955/new/

https://reviews.llvm.org/D76955





More information about the lldb-commits mailing list