summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-10-31 07:42:59 -0600
committerSimon Glass <sjg@chromium.org>2019-11-04 18:15:32 -0700
commitb4cf5f1df741e8781bed6149291823cd1a4b8baa (patch)
tree3128d78456e1b6877c23b42a59937399cdda839b /tools
parent5effab0549da404e0f2c21a3f7585aa643f54fc8 (diff)
downloadu-boot-b4cf5f1df741e8781bed6149291823cd1a4b8baa.tar.gz
u-boot-b4cf5f1df741e8781bed6149291823cd1a4b8baa.tar.bz2
u-boot-b4cf5f1df741e8781bed6149291823cd1a4b8baa.zip
pylibfdt: Convert to Python 3
Build this swig module with Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/binman/entry.py16
-rw-r--r--tools/binman/entry_test.py15
-rw-r--r--tools/binman/etype/intel_fit.py2
3 files changed, 3 insertions, 30 deletions
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 409c0dca93..5bf5be4794 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -7,16 +7,7 @@
from __future__ import print_function
from collections import namedtuple
-
-# importlib was introduced in Python 2.7 but there was a report of it not
-# working in 2.7.12, so we work around this:
-# http://lists.denx.de/pipermail/u-boot/2016-October/269729.html
-try:
- import importlib
- have_importlib = True
-except:
- have_importlib = False
-
+import importlib
import os
import sys
@@ -119,10 +110,7 @@ class Entry(object):
old_path = sys.path
sys.path.insert(0, os.path.join(our_path, 'etype'))
try:
- if have_importlib:
- module = importlib.import_module(module_name)
- else:
- module = __import__(module_name)
+ module = importlib.import_module(module_name)
except ImportError as e:
raise ValueError("Unknown entry type '%s' in node '%s' (expected etype/%s.py, error '%s'" %
(etype, node_path, module_name, e))
diff --git a/tools/binman/entry_test.py b/tools/binman/entry_test.py
index 13f5864516..277e10b585 100644
--- a/tools/binman/entry_test.py
+++ b/tools/binman/entry_test.py
@@ -39,21 +39,6 @@ class TestEntry(unittest.TestCase):
else:
import entry
- def test1EntryNoImportLib(self):
- """Test that we can import Entry subclassess successfully"""
- sys.modules['importlib'] = None
- global entry
- self._ReloadEntry()
- entry.Entry.Create(None, self.GetNode(), 'u-boot')
- self.assertFalse(entry.have_importlib)
-
- def test2EntryImportLib(self):
- del sys.modules['importlib']
- global entry
- self._ReloadEntry()
- entry.Entry.Create(None, self.GetNode(), 'u-boot-spl')
- self.assertTrue(entry.have_importlib)
-
def testEntryContents(self):
"""Test the Entry bass class"""
import entry
diff --git a/tools/binman/etype/intel_fit.py b/tools/binman/etype/intel_fit.py
index 23606d27d0..2a34a05f95 100644
--- a/tools/binman/etype/intel_fit.py
+++ b/tools/binman/etype/intel_fit.py
@@ -27,6 +27,6 @@ class Entry_intel_fit(Entry_blob):
self.align = 16
def ObtainContents(self):
- data = struct.pack('<8sIHBB', '_FIT_ ', 1, 0x100, 0x80, 0x7d)
+ data = struct.pack('<8sIHBB', b'_FIT_ ', 1, 0x100, 0x80, 0x7d)
self.SetContents(data)
return True