stella.stamenova created this revision.
stella.stamenova added reviewers: zturner, asmith.
Herald added a subscriber: lldb-commits.

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.

There are a pair of functions to_bytes/to_string in lit that implement the 
correct conversion, but they're not available throughout the lldb suite which 
is why this fix is 'in place' rather than calling one of these functions.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D53166

Files:
  packages/Python/lldbsuite/test/lldbtest.py


Index: packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -2227,6 +2227,10 @@
         # Get the error text if there was an error, and the regular text if 
not.
         output = self.res.GetOutput() if self.res.Succeeded() \
                 else self.res.GetError()
+        # In Python 2, communicate sends byte strings. In Python 3, 
communicate sends bytes.
+        # If we got a string (and not a byte string), encode it before sending.
+        if isinstance(output, str) and not isinstance(output, bytes):
+            output = output.encode()
 
         # Assemble the absolute path to the check file. As a convenience for
         # LLDB inline tests, assume that the check file is a relative path to


Index: packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -2227,6 +2227,10 @@
         # Get the error text if there was an error, and the regular text if not.
         output = self.res.GetOutput() if self.res.Succeeded() \
                 else self.res.GetError()
+        # In Python 2, communicate sends byte strings. In Python 3, communicate sends bytes.
+        # If we got a string (and not a byte string), encode it before sending.
+        if isinstance(output, str) and not isinstance(output, bytes):
+            output = output.encode()
 
         # Assemble the absolute path to the check file. As a convenience for
         # LLDB inline tests, assume that the check file is a relative path to
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to