dtoc: Use binary mode for reading files
authorSimon Glass <sjg@chromium.org>
Sat, 18 May 2019 04:00:39 +0000 (22:00 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 10 Jul 2019 22:52:58 +0000 (16:52 -0600)
The .dtb files are binary so we should open them as binary files. This
allows Python 3 to use the correct 'bytes' type.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/dtoc/test_fdt.py

index 3cd34b745eda7ce1a7f01a7f74850cc23b227a31..4c39f9a3e2811ab6e8975c0d3f6b67cf8f70b832 100755 (executable)
@@ -85,13 +85,13 @@ class TestFdt(unittest.TestCase):
     def testFlush(self):
         """Check that we can flush the device tree out to its file"""
         fname = self.dtb._fname
-        with open(fname) as fd:
+        with open(fname, 'rb') as fd:
             data = fd.read()
         os.remove(fname)
         with self.assertRaises(IOError):
-            open(fname)
+            open(fname, 'rb')
         self.dtb.Flush()
-        with open(fname) as fd:
+        with open(fname, 'rb') as fd:
             data = fd.read()
 
     def testPack(self):