From ca3dc019b78bb6557aea915ed0a50d2f67f8c068 Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Tue, 15 Oct 2024 08:58:36 +0200 Subject: [PATCH] scripts: Read yaml files using utf-8 encoding By default Windows does not use utf-8 encoding for reading files, set is explicitly. Signed-off-by: Pieter De Gendt --- scripts/ci/test_plan.py | 2 +- scripts/list_boards.py | 2 +- scripts/list_hardware.py | 2 +- scripts/utils/board_v1_to_v2.py | 2 +- scripts/zephyr_module.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/ci/test_plan.py b/scripts/ci/test_plan.py index 61305a75f45..326068ab715 100755 --- a/scripts/ci/test_plan.py +++ b/scripts/ci/test_plan.py @@ -246,7 +246,7 @@ class Filters: c = (zephyr_base / changed).resolve() if c.is_relative_to(board.dir.resolve()): for file in glob.glob(os.path.join(board.dir, f"{board.name}*.yaml")): - with open(file, 'r') as f: + with open(file, 'r', encoding='utf-8') as f: b = yaml.load(f.read(), Loader=SafeLoader) matched_boards[b['identifier']] = board diff --git a/scripts/list_boards.py b/scripts/list_boards.py index 4bc83df4652..bf716584885 100755 --- a/scripts/list_boards.py +++ b/scripts/list_boards.py @@ -183,7 +183,7 @@ def find_arch2board_set_in(root, arches, board_dir): def load_v2_boards(board_name, board_yml, systems): boards = [] if board_yml.is_file(): - with board_yml.open('r') as f: + with board_yml.open('r', encoding='utf-8') as f: b = yaml.load(f.read(), Loader=SafeLoader) try: diff --git a/scripts/list_hardware.py b/scripts/list_hardware.py index 1e994f3fd56..cce6fbe9831 100755 --- a/scripts/list_hardware.py +++ b/scripts/list_hardware.py @@ -188,7 +188,7 @@ def find_v2_archs(args): archs_yml = root / ARCHS_YML_PATH if Path(archs_yml).is_file(): - with Path(archs_yml).open('r') as f: + with Path(archs_yml).open('r', encoding='utf-8') as f: archs = yaml.load(f.read(), Loader=SafeLoader) try: diff --git a/scripts/utils/board_v1_to_v2.py b/scripts/utils/board_v1_to_v2.py index da84efb2ef9..ddaa01807c8 100644 --- a/scripts/utils/board_v1_to_v2.py +++ b/scripts/utils/board_v1_to_v2.py @@ -74,7 +74,7 @@ def board_v1_to_v2(board_root, board, new_board, group, vendor, soc, variants): } } else: - with open(board_settings_file) as f: + with open(board_settings_file, encoding='utf-8') as f: yaml = ruamel.yaml.YAML(typ='safe', pure=True) board_settings = yaml.load(f) # pylint: disable=assignment-from-no-return diff --git a/scripts/zephyr_module.py b/scripts/zephyr_module.py index c6043154bdc..62307896e9c 100755 --- a/scripts/zephyr_module.py +++ b/scripts/zephyr_module.py @@ -193,7 +193,7 @@ def process_module(module): for module_yml in [module_path / MODULE_YML_PATH, module_path / MODULE_YML_PATH.with_suffix('.yaml')]: if Path(module_yml).is_file(): - with Path(module_yml).open('r') as f: + with Path(module_yml).open('r', encoding='utf-8') as f: meta = yaml.load(f.read(), Loader=SafeLoader) try: