From 2c7f443ce0b3d92ea44acb440c1891344eacc6d4 Mon Sep 17 00:00:00 2001 From: KyleMiles Date: Fri, 13 Jul 2018 19:23:31 -0400 Subject: Python2/3 String Compatibility Fix --- python/databuffer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'python/databuffer.py') 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)) -- cgit v1.3.1