summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/lldbutil.py
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-01-25 23:21:18 +0000
committerZachary Turner <zturner@google.com>2016-01-25 23:21:18 +0000
commit4407396fb94dc3a1da5b51f9512381f9bb46ca64 (patch)
tree1117e1b13e0b664b9808a077d443c9d4f626f5ee /lldb/packages/Python/lldbsuite/test/lldbutil.py
parentbea3a85151ef5154f0c99722b5bad5bb56b2ac55 (diff)
downloadbcm5719-llvm-4407396fb94dc3a1da5b51f9512381f9bb46ca64.tar.gz
bcm5719-llvm-4407396fb94dc3a1da5b51f9512381f9bb46ca64.zip
Fix some issues with bytes and strings in Python 3.
SBProcess::ReadMemory and other related functions such as WriteMemory are returning Python string() objects. This means that in Python 3 that are returning Unicode objects. In reality they should be returning bytes objects which is the same as a string in Python 2, but different in Python 3. This patch updates the generated SWIG code to return Python bytes objects for all memory related functions. One quirk of this patch is that the C++ signature of ReadCStringFromMemory has it writing c-string data into a void*. This confuses our swig typemaps which expect that a void* means byte data. So I hacked up a custom typemap which maps this specific function to treat the void* as string data instead of byte data. llvm-svn: 258743
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lldbutil.py')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbutil.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 7aeffa37671..ea34ed6271e 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -84,7 +84,7 @@ def int_to_bytearray(val, bytesize):
return None
packed = struct.pack(fmt, val)
- return bytearray(list(map(ord, packed)))
+ return bytearray(packed)
def bytearray_to_int(bytes, bytesize):
"""Utility function to convert a bytearray into an integer.
@@ -108,7 +108,7 @@ def bytearray_to_int(bytes, bytesize):
else:
return None
- unpacked = struct.unpack(fmt, str(bytes))
+ unpacked = struct.unpack_from(fmt, bytes)
return unpacked[0]
OpenPOWER on IntegriCloud