Final switch from Python 2 to Python 3 for avbtool.
As of January 1st, 2020 Python 2 is not officially supported anymore:
https://www.python.org/dev/peps/pep-0373/#id4
As a consequence avbtool has been ported to Python 3 over the last
couple of changes in a still Python 2 compatible way. This particular
change is the last step in the porting work to switch over to Python 3
and breaks backward compatibility with Python 2 runtime environments.
Bug: 151336743
Test: atest --host libavb_host_unittest
Test: atest --host aftltool_test
Test: ./aftltool_integration_test.py
Change-Id: I4a93a644c427c0ca9be70addd0f26d5e4ff1556e
diff --git a/avbtool.py b/avbtool.py
index 85f8ca1..3f8421d 100755
--- a/avbtool.py
+++ b/avbtool.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright 2016, The Android Open Source Project
#
@@ -24,8 +24,6 @@
#
"""Command-line tool for working with Android Verified Boot images."""
-from __future__ import print_function
-
import argparse
import binascii
import bisect
@@ -3610,7 +3608,7 @@
# size as the hash size. Don't populate a random salt if this
# descriptor is being created to use a persistent digest on device.
hash_size = digest_size
- with open('/dev/urandom') as f:
+ with open('/dev/urandom', 'rb') as f:
salt = f.read(hash_size)
else:
salt = b''