diff options
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py index a9e553cbb7d..fb8f61bdf8c 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py @@ -4,6 +4,7 @@ import subprocess import threading import socket import lldb +from lldbsuite.support import seven from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbtest_config @@ -305,13 +306,9 @@ class MockGDBServer: data = None while True: try: - data = self._client.recv(4096) + data = seven.bitcast_to_string(self._client.recv(4096)) if data is None or len(data) == 0: break - # 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) except Exception as e: self._client.close() @@ -406,7 +403,7 @@ class MockGDBServer: # We'll handle the ack stuff here since it's not something any of the # tests will be concerned about, and it'll get turned off quickly anyway. if self._shouldSendAck: - self._client.sendall('+'.encode()) + self._client.sendall(seven.bitcast_to_bytes('+')) if packet == "QStartNoAckMode": self._shouldSendAck = False response = "OK" @@ -416,11 +413,7 @@ class MockGDBServer: # Handle packet framing since we don't want to bother tests with it. if response is not None: framed = frame_packet(response) - # 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() - self._client.sendall(framed) + self._client.sendall(seven.bitcast_to_bytes(framed)) PACKET_ACK = object() PACKET_INTERRUPT = object() @@ -504,4 +497,4 @@ class GDBRemoteTestBase(TestBase): j += 1 if i < len(packets): self.fail(u"Did not receive: %s\nLast 10 packets:\n\t%s" % - (packets[i], u'\n\t'.join(log[-10:]))) + (packets[i], u'\n\t'.join(log))) |