This is an archive of the discontinued LLVM Phabricator instance.

[lldbsuite] Fix the filecheck functionality to work with Python 3
ClosedPublic

Authored by stella.stamenova on Oct 11 2018, 1:38 PM.

Details

Summary

This is another string/byte conversion issue between Python 2 and 3. In Python 2, the subprocess communication expects a byte string, but in Python 3, it expects bytes. Since both versions are capable of using strings when universal_newlines is set to True AND filecheck operates on strings, force the use of strings.

Diff Detail

Repository
rLLDB LLDB

Event Timeline

zturner added inline comments.Oct 11 2018, 1:51 PM
packages/Python/lldbsuite/test/lldbtest.py
2230–2233

Ok I had to stare at this for a long time to figure out what was going on. I think you need to update the comment here, because it makes it sounds like output is the result of a Popen.communicate. But output is the result of a debugger.HandleCommand().

I think we should actually just leave this the way it was and fix it in the call to Popen (see below)

2243–2245

If I'm not mistaken, Python 3 can accept stdin as bytes or string, and either will work, it depends on the value of universal_newlines, and stdout will be in whatever format stdin was in. If we pass universal_newlines=True, then it will expect a string and output a string, otherwise it expects a bytes and output a bytes. Given that FileCheck is supposed to operate on textual data and not binary data, perhaps we should be doing that here?

stella.stamenova edited the summary of this revision. (Show Details)

Force the comparison in filecheck to use text rather than bytes

packages/Python/lldbsuite/test/lldbtest.py
2243–2245

Brilliant! :)

zturner accepted this revision.Oct 12 2018, 10:51 AM
This revision is now accepted and ready to land.Oct 12 2018, 10:51 AM
This revision was automatically updated to reflect the committed changes.