From: Simon Glass <sjg@chromium.org>
Date: Sat, 18 May 2019 04:00:39 +0000 (-0600)
Subject: dtoc: Use binary mode for reading files
X-Git-Tag: v2025.01-rc5-pxa1908~2888^2~45
X-Git-Url: http://git.dujemihanovic.xyz/img/html/static/%7B%7B%20%28.OutputFormats.Get?a=commitdiff_plain;h=2ab6e13e014c065a6168d31d6b8aeca135767816;p=u-boot.git

dtoc: Use binary mode for reading files

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>
---

diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index 3cd34b745e..4c39f9a3e2 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -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):