diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/binaryview.py | 2 | ||||
| -rw-r--r-- | python/compatibility.py | 2 | ||||
| -rw-r--r-- | python/databuffer.py | 3 |
3 files changed, 6 insertions, 1 deletions
diff --git a/python/binaryview.py b/python/binaryview.py index 49a80a4a..4a73a5a7 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -2680,7 +2680,7 @@ class BinaryView(object): >>> bv.read(0,4) 'AAAA' """ - if not isinstance(data, bytes): + if not (isinstance(data, bytes) or isinstance(data, bytearray)): if isinstance(data, str): buf = databuffer.DataBuffer(data.encode()) else: diff --git a/python/compatibility.py b/python/compatibility.py index 99411605..ccb185f8 100644 --- a/python/compatibility.py +++ b/python/compatibility.py @@ -83,6 +83,8 @@ def with_metaclass(meta, *bases): def cstr(arg): if isinstance(arg, bytes) or arg is None: return arg + elif isinstance(arg, bytearray): + return bytes(arg) else: try: return arg.encode('charmap') diff --git a/python/databuffer.py b/python/databuffer.py index d05ad1f5..26347101 100644 --- a/python/databuffer.py +++ b/python/databuffer.py @@ -39,6 +39,9 @@ class DataBuffer(object): else: if bytes != str and isinstance(contents, str): contents = contents.encode('charmap') + else: + if isinstance(contents, bytearray): + contents = bytes(contents) self.handle = core.BNCreateDataBuffer(contents, len(contents)) def __del__(self): |
