summaryrefslogtreecommitdiff
path: root/python/types.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/types.py')
-rw-r--r--python/types.py15
1 files changed, 4 insertions, 11 deletions
diff --git a/python/types.py b/python/types.py
index de4a080e..57c0824c 100644
--- a/python/types.py
+++ b/python/types.py
@@ -2196,11 +2196,7 @@ class Type:
@staticmethod
def named_type_from_registered_type(view: 'binaryview.BinaryView', name: QualifiedNameType) -> 'NamedTypeReferenceType':
- type = view.get_type_by_name(name)
- if type is None:
- raise ValueError(f"Type {name} does not exist in BinaryView")
- assert type.registered_name is not None
- return NamedTypeReferenceType.create_from_type(name, type, type.registered_name.type_id)
+ return NamedTypeReferenceType.create_from_registered_type(view, name)
@staticmethod
def enumeration_type(
@@ -2967,13 +2963,11 @@ class NamedTypeReferenceType(Type):
def __init__(
self, handle, platform: Optional['_platform.Platform'] = None, confidence: int = core.max_confidence, ntr_handle=None
):
- if handle is None:
- raise ValueError("Attempting to create NamedTypeReferenceType handle which is None")
+ assert handle is not None, "Attempting to create NamedTypeReferenceType handle which is None"
super(NamedTypeReferenceType, self).__init__(handle, platform, confidence)
if ntr_handle is None:
ntr_handle = core.BNGetTypeNamedTypeReference(handle)
- if ntr_handle is None:
- raise ValueError("No Registered NamedTypeReference exists for this type")
+ assert ntr_handle is not None, "core.BNGetTypeNamedTypeReference returned None"
self.ntr_handle = ntr_handle
def mutable_copy(self):
@@ -3012,8 +3006,7 @@ class NamedTypeReferenceType(Type):
const: BoolWithConfidenceType = False, volatile: BoolWithConfidenceType = False
):
"""Create a NamedTypeReferenceType from a BNNamedTypeReference handle"""
- if ntr_handle is None:
- raise ValueError("Attempting to create NamedTypeReferenceType from None handle")
+ assert ntr_handle is not None, "Attempting to create NamedTypeReferenceType from None handle"
_const = BoolWithConfidence.get_core_struct(const)
_volatile = BoolWithConfidence.get_core_struct(volatile)
core_type = core.BNCreateNamedTypeReference(ntr_handle, width, alignment, _const, _volatile)