[PATCH] D46773: [lit] Fix several tests that fail when using Python 3 or on Windows

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 11 14:53:12 PDT 2018


zturner added inline comments.


================
Comment at: packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py:281-285
+                # In Python 2, sockets return byte strings. In Python 3, sockets return bytes.
+                # If we got bytes (and not a byte string), decode them to a string for later handling.
+                if isinstance(data, bytes) and not isinstance(data, str):
+                    data = data.decode()
+                self._receive(data)
----------------
It's a shame that we're not using lit here.  lit has a nice function `lit.util.to_string` which handles this (and one other strange edge case) correctly.


================
Comment at: packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py:389-392
+            # In Python 2, sockets send byte strings. In Python 3, sockets send bytes.
+            # If we got a string (and not a byte string), encode it before sending.
+            if isinstance(framed, str) and not isinstance(framed, bytes):
+                framed = framed.encode()
----------------
Similarly here.


Repository:
  rL LLVM

https://reviews.llvm.org/D46773





More information about the llvm-commits mailing list