From patchwork Thu Oct 31 13:42:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1187489 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="FUq3B6pP"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 473msn0YThz9sP4 for ; Fri, 1 Nov 2019 00:50:04 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id D0527C21F80; Thu, 31 Oct 2019 13:45:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 402C8C21F3A; Thu, 31 Oct 2019 13:43:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7D521C21EF1; Thu, 31 Oct 2019 13:43:36 +0000 (UTC) Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) by lists.denx.de (Postfix) with ESMTPS id 62064C21F02 for ; Thu, 31 Oct 2019 13:43:36 +0000 (UTC) Received: by mail-il1-f173.google.com with SMTP id y5so5420185ilb.5 for ; Thu, 31 Oct 2019 06:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uWBFno2sM+BhqwLQsDf2vBXdPUXDDbJeE+rpysNIcSo=; b=FUq3B6pPLJj4CnLi/SmaC31FXGkHAo6A4to9kT7+ogNKbozXNn8D0NsRcel5E59aKP 73HAu6jnWoPgxAPrzd2FihvAifMy38d5Q9PZgnUOOZSRGcFnLQymnXR/56vOtySmNV+H AUhGy+1NZHwh0w6FahA3V9UAsqyESEOMENYlg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uWBFno2sM+BhqwLQsDf2vBXdPUXDDbJeE+rpysNIcSo=; b=ZXrOikczX2qFuVDsCnn+5U6CH0EPDjSlEwD9oOzaUmC8nZhd+lqAvOWHt06R6oNDYW 6v859EpWzCA4KNKV4BkD2Un17NVbyFPT9B0ueL4t/sfboeGLdIFkrSWie8l35V+YzRi8 wnAdmJhquqPjZLVOpM31Kyn0u2U/o3y9JhF4bgP0V+TDMc9JVymj0lWifsbT5zTMjGxK Z/mOcs6nm7TV4hyYSPreerpn9EqMaSmy9m5SGywFdn+0qXxcHdwe3ZCB63Gx+TLiUgyy VV0IxV9CrkvzDYSVCHOs61QBGn7bYVpaXOQRtIZhlx0/r2saxwg7ztwulNot0CAfLES/ Jppg== X-Gm-Message-State: APjAAAVPFnZZRkbgOljbZBe5txQLfkPngYPNIfCaiRxMa4FlTHUnPQhb NH3BfxPF8F5aB0ty4LTipcXXoqP0bODH8Q== X-Google-Smtp-Source: APXvYqzJuaFctVZJ1Kvu+AU28qFUSrcxvhPds2g8IY7CZYju6ZT/5SK9KVBw02wnkmJdBn6arbVGkQ== X-Received: by 2002:a92:7ec1:: with SMTP id q62mr2721209ill.286.1572529415148; Thu, 31 Oct 2019 06:43:35 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id s70sm539612ili.13.2019.10.31.06.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 06:43:34 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 31 Oct 2019 07:42:59 -0600 Message-Id: <20191031134310.3072-10-sjg@chromium.org> X-Mailer: git-send-email 2.24.0.rc0.303.g954a862665-goog In-Reply-To: <20191031134310.3072-1-sjg@chromium.org> References: <20191031134310.3072-1-sjg@chromium.org> MIME-Version: 1.0 Cc: Tom Rini , Josef Lusticky Subject: [U-Boot] [PATCH v2 10/17] pylibfdt: Convert to Python 3 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Build this swig module with Python 3. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v2: None scripts/dtc/pylibfdt/Makefile | 2 +- scripts/dtc/pylibfdt/libfdt.i_shipped | 2 +- scripts/dtc/pylibfdt/setup.py | 2 +- tools/binman/entry.py | 16 ++-------------- tools/binman/entry_test.py | 15 --------------- tools/binman/etype/intel_fit.py | 2 +- 6 files changed, 6 insertions(+), 33 deletions(-) diff --git a/scripts/dtc/pylibfdt/Makefile b/scripts/dtc/pylibfdt/Makefile index 15e66ad44d..42342c75bb 100644 --- a/scripts/dtc/pylibfdt/Makefile +++ b/scripts/dtc/pylibfdt/Makefile @@ -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) diff --git a/scripts/dtc/pylibfdt/libfdt.i_shipped b/scripts/dtc/pylibfdt/libfdt.i_shipped index 76e61e98bd..53b70f8f5e 100644 --- a/scripts/dtc/pylibfdt/libfdt.i_shipped +++ b/scripts/dtc/pylibfdt/libfdt.i_shipped @@ -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) diff --git a/scripts/dtc/pylibfdt/setup.py b/scripts/dtc/pylibfdt/setup.py index 4f7cf042bf..992cdec30f 100755 --- a/scripts/dtc/pylibfdt/setup.py +++ b/scripts/dtc/pylibfdt/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 """ setup.py file for SWIG libfdt 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