diff options
| author | Peter LaFosse <peter@vector35.com> | 2021-09-06 11:38:59 -0400 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2021-09-06 11:46:44 -0400 |
| commit | 5a1f98b0e46d0077f777cb90e7d9d916c9186535 (patch) | |
| tree | f90bcc662dcf85fad1d2b5ef262568e5dc905d2e /python/flowgraph.py | |
| parent | a377529b29b43e35cce8763ec4077b329b218f43 (diff) | |
Fix some unnecessary checks for handle is not None in destructors
Diffstat (limited to 'python/flowgraph.py')
| -rw-r--r-- | python/flowgraph.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/python/flowgraph.py b/python/flowgraph.py index 922cc933..1d3d9504 100644 --- a/python/flowgraph.py +++ b/python/flowgraph.py @@ -21,6 +21,7 @@ import ctypes import threading import traceback +from typing import Optional # Binary Ninja components import binaryninja @@ -96,7 +97,7 @@ class FlowGraphNode: self._graph = FlowGraph(handle = core.BNGetFlowGraphNodeOwner(self.handle)) def __del__(self): - if self.handle is not None: + if core is not None: core.BNFreeFlowGraphNode(self.handle) def __repr__(self): @@ -398,8 +399,9 @@ class FlowGraph: """ _registered_instances = [] - def __init__(self, handle = None): - if handle is None: + def __init__(self, handle:Optional[core.BNCustomFlowGraphHandle] = None): + _handle = handle + if _handle is None: self._ext_cb = core.BNCustomFlowGraph() self._ext_cb.context = 0 self._ext_cb.prepareForLayout = self._ext_cb.prepareForLayout.__class__(self._prepare_for_layout) @@ -408,9 +410,9 @@ class FlowGraph: self._ext_cb.update = self._ext_cb.update.__class__(self._update) self._ext_cb.externalRefTaken = self._ext_cb.externalRefTaken.__class__(self._external_ref_taken) self._ext_cb.externalRefReleased = self._ext_cb.externalRefReleased.__class__(self._external_ref_released) - handle = core.BNCreateCustomFlowGraph(self._ext_cb) - assert handle is not None - self.handle = handle + _handle = core.BNCreateCustomFlowGraph(self._ext_cb) + assert _handle is not None + self.handle = _handle def __del__(self): if core is not None: @@ -433,7 +435,6 @@ class FlowGraph: return not (self == other) def __hash__(self): - assert self.handle is not None return hash(ctypes.addressof(self.handle.contents)) def __setattr__(self, name, value): |
