From 7f2d3ad1f37f8944d0158448072d2db5b167fa43 Mon Sep 17 00:00:00 2001 From: Xusheng Date: Fri, 16 Dec 2022 11:32:26 +0800 Subject: Use .length method to get the length of a Section object and deprecate len(). Fix https://github.com/Vector35/binaryninja-api/issues/3634 --- python/binaryview.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'python') 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"
" + @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__): @@ -1462,9 +1466,13 @@ class Section: def auto_defined(self) -> bool: 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: -- cgit v1.3.1