Changelog: bv.write and bv.insert require a bytes object in python3 Architecture.assemble outputs a bytes object in python3, a str in python2 Architecture.assemble will throw a value error if it cannot assemble the given instruction API install script should be run in the version of python you want it installed in Fundamental python changes to be aware of: Unicode-type strings are now just str, consequently anything that came out as a unicode string before (annotations) are now just str. Longs no longer exist. They're just ints.
Diffstat (limited to 'python/examples/bin_info.py')
-rw-r--r--python/examples/bin_info.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/python/examples/bin_info.py b/python/examples/bin_info.py
index 17a96685..05a72ed0 100644
--- a/python/examples/bin_info.py
+++ b/python/examples/bin_info.py
@@ -20,11 +20,15 @@
# IN THE SOFTWARE.
import sys
+
import binaryninja.log as log
from binaryninja.binaryview import BinaryViewType
import binaryninja.interaction as interaction
from binaryninja.plugin import PluginCommand
+# 2-3 compatibility
+from binaryninja import range
+
def get_bininfo(bv):
if bv is None:
@@ -48,13 +52,13 @@ def get_bininfo(bv):
contents += "| Start | Name |\n"
contents += "|------:|:-------|\n"
- for i in xrange(min(10, len(bv.functions))):
+ for i in range(min(10, len(bv.functions))):
contents += "| 0x%x | %s |\n" % (bv.functions[i].start, bv.functions[i].symbol.full_name)
contents += "### First 10 Strings ###\n"
contents += "| Start | Length | String |\n"
contents += "|------:|-------:|:-------|\n"
- for i in xrange(min(10, len(bv.strings))):
+ for i in range(min(10, len(bv.strings))):
start = bv.strings[i].start
length = bv.strings[i].length
string = bv.read(start, length)
@@ -67,6 +71,6 @@ def display_bininfo(bv):
if __name__ == "__main__":
- print get_bininfo(None)
+ print(get_bininfo(None))
else:
PluginCommand.register("Binary Info", "Display basic info about the binary", display_bininfo)