summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2020-06-16 19:04:07 -0400
committerRusty Wagner <rusty@vector35.com>2020-06-16 19:04:07 -0400
commit8ef7fc54f93a041725dbd4d7bf2a8be159e3ee6f (patch)
tree7afc6d4344c63f6799bc9feeb1212bfecf2dfd1b
parent75588da11bc29b00cac46c494ea389ac87b49778 (diff)
Use Python 3 for bininfo test
-rw-r--r--python/examples/bin_info.py4
-rw-r--r--suite/testcommon.py8
2 files changed, 8 insertions, 4 deletions
diff --git a/python/examples/bin_info.py b/python/examples/bin_info.py
index 6b87eaf0..f74b9466 100644
--- a/python/examples/bin_info.py
+++ b/python/examples/bin_info.py
@@ -63,6 +63,10 @@ def get_bininfo(bv):
start = bv.strings[i].start
length = bv.strings[i].length
string = bv.read(start, length)
+ try:
+ string = string.decode('utf8')
+ except UnicodeDecodeError:
+ pass
contents += "| 0x%x |%d | %s |\n" % (start, length, string)
return contents
diff --git a/suite/testcommon.py b/suite/testcommon.py
index 25a8b4a5..0499d294 100644
--- a/suite/testcommon.py
+++ b/suite/testcommon.py
@@ -650,11 +650,11 @@ class TestBuilder(Builder):
file_name = self.unpackage_file("helloworld")
try:
bin_info_path = os.path.join(os.path.dirname(__file__), '..', 'python', 'examples', 'bin_info.py')
- if sys.platform == "linux" or sys.platform == "linux2":
- python_bin = "python2"
+ if sys.platform == "win32":
+ python_bin = ["py", "-3"]
else:
- python_bin = "python"
- result = subprocess.Popen([python_bin, bin_info_path, file_name], stdout=subprocess.PIPE).communicate()[0]
+ python_bin = ["python3"]
+ result = subprocess.Popen(python_bin + [bin_info_path, file_name], stdout=subprocess.PIPE).communicate()[0]
# normalize line endings and path sep
return [line for line in result.replace(b"\\", b"/").replace(b"\r\n", b"\n").decode("charmap").split("\n")]
finally: