From 1dc43605df780c32ae0d1be2f251465ed21c29cb Mon Sep 17 00:00:00 2001 From: Hake Huang Date: Wed, 6 Dec 2023 17:20:03 +0800 Subject: [PATCH] tests: testinstance: enforce utf-8 write as in windows platfrom the format by default is not utf-8, and we will see below error Traceback (most recent call last): File "...zephyr\scripts\twister", line 211, in ret = main(options) ^^^^^^^^^^^^^ File "...scripts/pylib/twister\twisterlib\twister_main.py", tplan.load() File "...scripts/pylib/twister\twisterlib\testplan.py", self.load_from_file(last_run, filter_platform=connected_list) File "...scripts/pylib/twister\twisterlib\testplan.py", instance.create_overlay(platform, self.options.enable_asan, self.options.enable_ubsan, self.options.enable_coverage, self.options.coverage_platform) File "...scripts/pylib/twister\twisterlib\testinstance.py" f.write(content) UnicodeEncodeError: 'gbk' codec can't encode character '\xf8' in position 64: illegal multibyte sequence Signed-off-by: Hake Huang --- scripts/pylib/twister/twisterlib/testinstance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pylib/twister/twisterlib/testinstance.py b/scripts/pylib/twister/twisterlib/testinstance.py index 438572040ca..24ab66ae030 100644 --- a/scripts/pylib/twister/twisterlib/testinstance.py +++ b/scripts/pylib/twister/twisterlib/testinstance.py @@ -287,7 +287,7 @@ class TestInstance: if content: os.makedirs(subdir, exist_ok=True) file = os.path.join(subdir, "testsuite_extra.conf") - with open(file, "w") as f: + with open(file, "w", encoding='utf-8') as f: f.write(content) return content