summaryrefslogtreecommitdiff
path: root/python/binaryview.py
diff options
context:
space:
mode:
authorJordan Wiens <jordan@psifertex.com>2021-09-29 12:05:43 -0400
committerJordan Wiens <jordan@psifertex.com>2021-09-29 12:06:16 -0400
commitdf006f45a34d91dce1186992a30665e733932329 (patch)
treed65a922d9e037821bb19c63cb9df1f2eb28566e2 /python/binaryview.py
parent9ba094fe0693e43f4beb5f1cba7b9bb59df76069 (diff)
add explanation of save options and warnings on get_view_of_file APIs
Diffstat (limited to 'python/binaryview.py')
-rw-r--r--python/binaryview.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index 76794c9d..c5f8b500 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -711,6 +711,12 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
"""
``get_view_of_file`` opens and returns the first available :py:class:`BinaryView`, excluding a Raw :py:class:`BinaryViewType` unless no other view is available
+ .. warning:: The recommended code pattern for opening a BinaryView is to use the \
+ ``open_view`` API as a context manager like ``with open_view('/bin/ls') as bv:`` \
+ which will automatically clean up when done with the view. If using this API directly \
+ you will need to call `bv.file.close()` before the BinaryView leaves scope to ensure the \
+ reference is properly removed and prevents memory leaks.
+
:param str filename: path to filename or bndb to open
: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
@@ -775,6 +781,12 @@ class BinaryViewType(metaclass=_BinaryViewTypeMetaclass):
>>> bv = BinaryViewType.get_view_of_file_with_options('/bin/ls', options={'files.universal.architecturePreference': ['arm64']})
+ .. warning:: The recommended code pattern for opening a BinaryView is to use the \
+ ``open_view`` API as a context manager like ``with open_view('/bin/ls') as bv:`` \
+ which will automatically clean up when done with the view. If using this API directly \
+ you will need to call `bv.file.close()` before the BinaryView leaves scope to ensure the \
+ reference is properly removed and prevents memory leaks.
+
:param str filename: path to filename or bndb to open
: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