diff options
| author | Peter LaFosse <peter@vector35.com> | 2021-07-29 13:09:04 -0400 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2021-09-05 10:09:10 -0400 |
| commit | c7b9b0330bc3b7121d8664a3eeec174739e5cc5e (patch) | |
| tree | e75ffcd2900e4ce9e68d362eb285dca04094f522 /python/binaryview.py | |
| parent | a24b82f9b3d5dbb76f700664a97f3d4904acce30 (diff) | |
Fix data accessors to return bytes objects instead of chr
Diffstat (limited to 'python/binaryview.py')
| -rw-r--r-- | python/binaryview.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/python/binaryview.py b/python/binaryview.py index 449d38cb..8984154a 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -1453,7 +1453,7 @@ class BinaryView: finally: core.BNFreeFunctionList(funcs, count.value) - def __getitem__(self, i): + def __getitem__(self, i) -> bytes: if isinstance(i, tuple): result = bytes() for s in i: @@ -1466,19 +1466,19 @@ class BinaryView: start = i[0] stop = i[1] if stop <= start: - return "" + return b"" return self.read(start, stop - start) elif i < 0: if i >= -len(self): value = self.read(int(len(self) + i), 1) if len(value) == 0: - return IndexError("index not readable") + raise IndexError("index not readable") return value raise IndexError("index out of range") elif (i >= self.start) and (i < self.end): value = self.read(int(i), 1) if len(value) == 0: - return IndexError("index not readable") + raise IndexError("index not readable") return value else: raise IndexError("index out of range") @@ -3985,6 +3985,7 @@ class BinaryView: return [] for src_func in funcs: src_arch = src_func.arch if arch is None else arch + assert src_arch is not None ref_src = core.BNReferenceSource(src_func.handle, src_arch.handle, addr) count = ctypes.c_ulonglong(0) refs = core.BNGetCallees(self.handle, ref_src, count) |
