From patchwork Thu Dec 11 17:59:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 76311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8638FD41D7E for ; Thu, 11 Dec 2025 17:59:14 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.16102.1765475951649160324 for ; Thu, 11 Dec 2025 09:59:11 -0800 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 12D391063 for ; Thu, 11 Dec 2025 09:59:04 -0800 (PST) Received: from cesw-amp-gbt-1s-m12830-04.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E52E03F73B for ; Thu, 11 Dec 2025 09:59:10 -0800 (PST) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH 1/3] oeqa: open JSON to parse in a context manager Date: Thu, 11 Dec 2025 17:59:06 +0000 Message-ID: <20251211175908.3952420-1-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 11 Dec 2025 17:59:14 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227561 Use context managers to open the .json files we're about to parse, so that python doesn't warn about unclosed files. Signed-off-by: Ross Burton --- meta/classes-recipe/testexport.bbclass | 3 ++- meta/lib/oeqa/sdk/testmetaidesupport.py | 3 ++- meta/lib/oeqa/sdk/testsdk.py | 3 ++- meta/lib/oeqa/sdkext/testsdk.py | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/meta/classes-recipe/testexport.bbclass b/meta/classes-recipe/testexport.bbclass index 344ae489b5a..12b7e171129 100644 --- a/meta/classes-recipe/testexport.bbclass +++ b/meta/classes-recipe/testexport.bbclass @@ -52,7 +52,8 @@ def testexport_main(d): d.getVar('IMAGE_LINK_NAME') or d.getVar('IMAGE_NAME'))) tdname = "%s.testdata.json" % image_name - td = json.load(open(tdname, "r")) + with open(tdname, "r") as f: + td = json.load(f) logger = logging.getLogger("BitBake") diff --git a/meta/lib/oeqa/sdk/testmetaidesupport.py b/meta/lib/oeqa/sdk/testmetaidesupport.py index 00ef30e82e9..1110c40b9bf 100644 --- a/meta/lib/oeqa/sdk/testmetaidesupport.py +++ b/meta/lib/oeqa/sdk/testmetaidesupport.py @@ -21,7 +21,8 @@ class TestSDK(object): sdk_envs = OESDKTestContextExecutor._get_sdk_environs(d.getVar("DEPLOY_DIR_IMAGE")) tdname = d.expand("${DEPLOY_DIR_IMAGE}/${PN}.testdata.json") - test_data = json.load(open(tdname, "r")) + with open(tdname, "r") as f: + test_data = json.load(f) host_pkg_manifest = {"cmake-native":"", "gcc-cross":"", "gettext-native":"", "meson-native":"", "perl-native":"", "python3-core-native":"", } target_pkg_manifest = {"gtk+3":""} diff --git a/meta/lib/oeqa/sdk/testsdk.py b/meta/lib/oeqa/sdk/testsdk.py index cffcf9f49a9..98ef9c71cd6 100644 --- a/meta/lib/oeqa/sdk/testsdk.py +++ b/meta/lib/oeqa/sdk/testsdk.py @@ -103,7 +103,8 @@ class TestSDK(TestSDKBase): bb.fatal("The toolchain %s is not built. Build it before running the tests: 'bitbake -c populate_sdk' ." % tcname) tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.testdata.json") - test_data = json.load(open(tdname, "r")) + with open(tdname, "r") as f: + test_data = json.load(f) target_pkg_manifest = self.context_executor_class._load_manifest( d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest")) diff --git a/meta/lib/oeqa/sdkext/testsdk.py b/meta/lib/oeqa/sdkext/testsdk.py index 6dc23065a4a..4d626f3e0c2 100644 --- a/meta/lib/oeqa/sdkext/testsdk.py +++ b/meta/lib/oeqa/sdkext/testsdk.py @@ -35,7 +35,8 @@ class TestSDKExt(TestSDKBase): " tests: 'bitbake -c populate_sdk_ext' ." % tcname) tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.testdata.json") - test_data = json.load(open(tdname, "r")) + with open(tdname, "r") as f: + test_data = json.load(f) target_pkg_manifest = OESDKExtTestContextExecutor._load_manifest( d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest")) From patchwork Thu Dec 11 17:59:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 76310 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8837FD41D7C for ; Thu, 11 Dec 2025 17:59:14 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.16123.1765475952260677105 for ; Thu, 11 Dec 2025 09:59:12 -0800 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B79B41063 for ; Thu, 11 Dec 2025 09:59:04 -0800 (PST) Received: from cesw-amp-gbt-1s-m12830-04.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8D2FD3F73B for ; Thu, 11 Dec 2025 09:59:11 -0800 (PST) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH 2/3] scripts/patchreview: use context manager when opening file Date: Thu, 11 Dec 2025 17:59:07 +0000 Message-ID: <20251211175908.3952420-2-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251211175908.3952420-1-ross.burton@arm.com> References: <20251211175908.3952420-1-ross.burton@arm.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 11 Dec 2025 17:59:14 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227562 To avoid warnings about unclosed files. Signed-off-by: Ross Burton --- scripts/contrib/patchreview.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/contrib/patchreview.py b/scripts/contrib/patchreview.py index d8d7b214e5c..dcf20937a8f 100755 --- a/scripts/contrib/patchreview.py +++ b/scripts/contrib/patchreview.py @@ -253,7 +253,8 @@ if __name__ == "__main__": if args.json: if os.path.isfile(args.json): - data = json.load(open(args.json)) + with open(args.json) as f: + data = json.load(f) else: data = [] From patchwork Thu Dec 11 17:59:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 76312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 915ACD43341 for ; Thu, 11 Dec 2025 17:59:14 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.16103.1765475953050079957 for ; Thu, 11 Dec 2025 09:59:13 -0800 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6870B1063 for ; Thu, 11 Dec 2025 09:59:05 -0800 (PST) Received: from cesw-amp-gbt-1s-m12830-04.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3DDD63F73B for ; Thu, 11 Dec 2025 09:59:12 -0800 (PST) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH 3/3] oe-setup-build: use context manager when loading JSON Date: Thu, 11 Dec 2025 17:59:08 +0000 Message-ID: <20251211175908.3952420-3-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251211175908.3952420-1-ross.burton@arm.com> References: <20251211175908.3952420-1-ross.burton@arm.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 11 Dec 2025 17:59:14 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/227563 Use a context manager to avoid warnings about unclosed files. Signed-off-by: Ross Burton --- scripts/oe-setup-build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/oe-setup-build b/scripts/oe-setup-build index edbcd48355a..b391f3b9254 100755 --- a/scripts/oe-setup-build +++ b/scripts/oe-setup-build @@ -21,7 +21,10 @@ def discover_templates(layers_file): raise Exception("List of layers {} does not exist; were the layers set up using the setup-layers script or bitbake-setup tool?".format(layers_file)) templates = [] - layers_list = json.load(open(layers_file))["layers"] + + with open(layers_file) as f: + layers_list = json.load(f)["layers"] + for layer in layers_list: template_dir = os.path.join(os.path.dirname(layers_file), layer, 'conf','templates') if os.path.exists(template_dir):