diff options
| author | Xusheng <xusheng@vector35.com> | 2022-12-16 11:32:26 +0800 |
|---|---|---|
| committer | Xusheng <xusheng@vector35.com> | 2022-12-16 11:32:26 +0800 |
| commit | 7f2d3ad1f37f8944d0158448072d2db5b167fa43 (patch) | |
| tree | 876ca11a491f686d9d0d493854a9ba8ef37ffe12 /python | |
| parent | 1bb356c14265190db7070266e15a1fcbdad4033a (diff) | |
Use .length method to get the length of a Section object and deprecate len(). Fix https://github.com/Vector35/binaryninja-api/issues/3634
Diffstat (limited to 'python')
| -rw-r--r-- | python/binaryview.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/python/binaryview.py b/python/binaryview.py index b60259f3..c744b670 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -1403,8 +1403,12 @@ class Section: def __repr__(self): return f"<section {self.name}: {self.start:#x}-{self.end:#x}>" + @decorators.deprecated def __len__(self): - return core.BNSectionGetLength(self.handle) + # deprecated - Python does allow the returning of integers >= 0x8000000000000000 + # please use .length instead + # for more information about this limitation in python see https://bugs.python.org/issue21444 + return self.length def __eq__(self, other): if not isinstance(other, self.__class__): @@ -1463,8 +1467,12 @@ class Section: return core.BNSectionIsAutoDefined(self.handle) @property + def length(self): + return int(core.BNSectionGetLength(self.handle)) + + @property def end(self) -> int: - return self.start + len(self) + return self.start + self.length class TagType: |
