summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2022-05-23 16:27:38 -0400
committerPeter LaFosse <peter@vector35.com>2022-05-23 16:42:12 -0400
commite18983f13a9b1356096745e98928b58ca10852c0 (patch)
treede222389ce102c813db7765e9b68072a8c186267
parenta8e650a8199577bfc5cbfb675a1150f47c569e54 (diff)
Esure parse_types api raise proper exceptions
-rw-r--r--python/binaryview.py2
-rw-r--r--suite/api_test.py5
2 files changed, 6 insertions, 1 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index 2db75717..405afcc6 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -6203,7 +6203,7 @@ class BinaryView:
>>>
"""
if not isinstance(text, str):
- raise AttributeError("Source must be a string")
+ raise ValueError("Source must be a string")
parse = core.BNTypeParserResult()
try:
diff --git a/suite/api_test.py b/suite/api_test.py
index 3fd3dbb0..c77b5fc9 100644
--- a/suite/api_test.py
+++ b/suite/api_test.py
@@ -2780,6 +2780,11 @@ class TestBinaryView(TestWithBinaryView):
assert a.return_value == b.return_value
assert a.parameters == b.parameters
+ self.assertRaises(ValueError, lambda: self.bv.parse_type_string(None))
+ self.assertRaises(SyntaxError, lambda: self.bv.parse_type_string("a"))
+ self.assertRaises(ValueError, lambda: self.bv.parse_types_from_string(None))
+ self.assertRaises(SyntaxError, lambda: self.bv.parse_types_from_string("a"))
+
class TestBinaryViewType(unittest.TestCase):