]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
pylibfdt: Convert to Python 3
authorSimon Glass <sjg@chromium.org>
Thu, 31 Oct 2019 13:42:59 +0000 (07:42 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 5 Nov 2019 01:15:32 +0000 (18:15 -0700)
Build this swig module with Python 3.

Signed-off-by: Simon Glass <sjg@chromium.org>
scripts/dtc/pylibfdt/Makefile
scripts/dtc/pylibfdt/libfdt.i_shipped
scripts/dtc/pylibfdt/setup.py
tools/binman/entry.py
tools/binman/entry_test.py
tools/binman/etype/intel_fit.py

index 15e66ad44d76004f15f08d014ed03a5d101e14e2..42342c75bb19f2c36b274768d0ed517a0ef9688c 100644 (file)
@@ -21,7 +21,7 @@ quiet_cmd_pymod = PYMOD   $@
                CPPFLAGS="$(HOSTCFLAGS) -I$(LIBFDT_srcdir)" OBJDIR=$(obj) \
                SOURCES="$(PYLIBFDT_srcs)" \
                SWIG_OPTS="-I$(LIBFDT_srcdir) -I$(LIBFDT_srcdir)/.." \
-               $(PYTHON2) $< --quiet build_ext --inplace
+               $(PYTHON3) $< --quiet build_ext --inplace
 
 $(obj)/_libfdt.so: $(src)/setup.py $(PYLIBFDT_srcs) FORCE
        $(call if_changed,pymod)
index 76e61e98bdf06137eec93dd8c27bb41586a40994..53b70f8f5e7061ae43eec7a23f723dc2bf79776f 100644 (file)
@@ -624,7 +624,7 @@ class Fdt(FdtRo):
         Raises:
             FdtException if no parent found or other error occurs
         """
-        val = val.encode('utf-8') + '\0'
+        val = val.encode('utf-8') + b'\0'
         return check_err(fdt_setprop(self._fdt, nodeoffset, prop_name,
                                      val, len(val)), quiet)
 
index 4f7cf042bfe74380a36c040da4969da3ea1e9870..992cdec30f55238f09e3e3545848e9c31282da6d 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
 
 """
 setup.py file for SWIG libfdt
index 409c0dca9345df5898b0dc31214a88a0149286d1..5bf5be4794b4c92f87ff492df2dba0b29d963d70 100644 (file)
@@ -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))
index 13f58645168e26d87088453add64454ff404e601..277e10b5859f493361f08961d45b9bccdaf8ce20 100644 (file)
@@ -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
index 23606d27d04ab550c8dbd175c238520294bb4cc1..2a34a05f95554b2cf75b8b6ae71bb4c5d4f8efff 100644 (file)
@@ -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