[Lldb-commits] [PATCH] D16680: Re-submit rL258759: Write the session log file in UTF-8.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 28 08:45:05 PST 2016


Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> dir(str)
['__add__', '__class__', '__contains__', '__delattr__', '__dir__',
'__doc__', '__eq__', '__format__', '__ge__', '__getattribute__',
'__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__',
'__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__',
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__',
'__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__',
'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith',
'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum',
'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric',
'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower',
'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust',
'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith',
'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
>>>

No decode method.  Which gets to the heart of the problem, I couldn't find
a single syntax that worked on all platforms :-/

I think the best thing to do is make a decode_utf8() function that looks
like this:

def decode_utf8(text):
    if six.PY2:
        return text.decode("utf-8", errors="replace")
    return text

and then write

print(decode_utf8(traceback), file=self.session)

and make sure that the file is opened with io.open(encoding="utf-8")



On Thu, Jan 28, 2016 at 7:12 AM Tamas Berghammer <tberghammer at google.com>
wrote:

> tberghammer added a comment.
>
> I am more worried about Windows and python3 and I don't think we have any
> build bot running the tests on Windows. I don't really know what is the
> original issue this commit try to address so I plan to wait until Zachary
> can check it out (the current ToT works on Linux so I am not worried)
>
>
> http://reviews.llvm.org/D16680
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160128/498d98db/attachment.html>


More information about the lldb-commits mailing list