diff options
| author | Josh F <josh@vector35.com> | 2022-08-05 22:20:47 -0400 |
|---|---|---|
| committer | Josh F <josh@vector35.com> | 2022-08-05 22:24:59 -0400 |
| commit | c6b12bab36a05b1efb55709ed4f6aba9a8886080 (patch) | |
| tree | f34639141afc8fac8657a23ca476e5f71b736537 /python/__init__.py | |
| parent | 4e2b30a701c48c7afe04a757652a75e38a88b8d6 (diff) | |
Raise Exception instead of returning None from open_view and load
Diffstat (limited to 'python/__init__.py')
| -rw-r--r-- | python/__init__.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/python/__init__.py b/python/__init__.py index b14802b1..ef316c36 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -298,7 +298,7 @@ def get_memory_usage_info() -> Mapping[str, int]: return result -def load(*args, **kwargs) -> Optional[BinaryView]: +def load(*args, **kwargs) -> BinaryView: """ `load` is a convenience wrapper for :py:class:`BinaryViewType.load` that opens a BinaryView object. @@ -306,8 +306,9 @@ def load(*args, **kwargs) -> Optional[BinaryView]: :param bool update_analysis: whether or not to run :func:`update_analysis_and_wait` after opening a :py:class:`BinaryView`, defaults to ``True`` :param callback progress_func: optional function to be called with the current progress and total count :param dict options: a dictionary in the form {setting identifier string : object value} - :return: returns a :py:class:`BinaryView` object for the given filename or ``None`` - :rtype: :py:class:`BinaryView` or ``None`` + :return: returns a :py:class:`BinaryView` object for the given filename + :rtype: :py:class:`BinaryView` + :raises Exception: When a BinaryView could not be created :Example: >>> from binaryninja import * @@ -321,10 +322,13 @@ def load(*args, **kwargs) -> Optional[BinaryView]: ... 1 """ - return BinaryViewType.load(*args, **kwargs) + bv = BinaryViewType.load(*args, **kwargs) + if bv is None: + raise Exception("Unable to create new BinaryView") + return bv -def open_view(*args, **kwargs) -> Optional[BinaryView]: +def open_view(*args, **kwargs) -> BinaryView: """ `open_view` is a convenience wrapper for :py:class:`get_view_of_file_with_options` that opens a BinaryView object. @@ -334,8 +338,9 @@ def open_view(*args, **kwargs) -> Optional[BinaryView]: :param bool update_analysis: whether or not to run :func:`update_analysis_and_wait` after opening a :py:class:`BinaryView`, defaults to ``True`` :param callback progress_func: optional function to be called with the current progress and total count :param dict options: a dictionary in the form {setting identifier string : object value} - :return: returns a :py:class:`BinaryView` object for the given filename or ``None`` - :rtype: :py:class:`BinaryView` or ``None`` + :return: returns a :py:class:`BinaryView` object for the given filename + :rtype: :py:class:`BinaryView` + :raises Exception: When a BinaryView could not be created :Example: >>> from binaryninja import * @@ -345,7 +350,10 @@ def open_view(*args, **kwargs) -> Optional[BinaryView]: 128 """ - return BinaryViewType.get_view_of_file_with_options(*args, **kwargs) + bv = BinaryViewType.get_view_of_file_with_options(*args, **kwargs) + if bv is None: + raise Exception("Unable to create new BinaryView") + return bv def connect_pycharm_debugger(port=5678): |
