summaryrefslogtreecommitdiff
path: root/python/databuffer.py
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2018-07-13 19:23:31 -0400
committerKyleMiles <krm504@nyu.edu>2018-07-13 19:25:15 -0400
commit2c7f443ce0b3d92ea44acb440c1891344eacc6d4 (patch)
tree2b792808b858de83d7f2b90040b023534a4455a6 /python/databuffer.py
parentb460b9495a91897d9f8ed192c148e5afc366fb59 (diff)
Python2/3 String Compatibility Fix
Diffstat (limited to 'python/databuffer.py')
-rw-r--r--python/databuffer.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/python/databuffer.py b/python/databuffer.py
index 298d0002..2fb5382d 100644
--- a/python/databuffer.py
+++ b/python/databuffer.py
@@ -23,6 +23,9 @@ import ctypes
# Binary Ninja components
from binaryninja import _binaryninjacore as core
+# 2-3 compatibility
+from binaryninja import pyNativeStr
+
class DataBuffer(object):
def __init__(self, contents="", handle=None):
@@ -114,10 +117,7 @@ class DataBuffer(object):
def __str__(self):
buf = ctypes.create_string_buffer(len(self))
ctypes.memmove(buf, core.BNGetDataBufferContents(self.handle), len(self))
- if isinstance(buf.raw, str):
- return buf.raw
- else:
- return buf.raw.decode("charmap")
+ return pyNativeStr(buf.raw)
def __bytes__(self):
buf = ctypes.create_string_buffer(len(self))