feat(tools): Enforce utf-8 encoding with open() function

This commit is contained in:
Marek Fiala
2024-07-23 15:59:09 +02:00
committed by BOT
parent 305f1c1e5b
commit 2c814ef2fa
40 changed files with 115 additions and 124 deletions

View File

@@ -481,7 +481,7 @@ def init_cli(verbose_output: Optional[List]=None) -> Any:
# Otherwise, if we built any binaries print a message about
# how to flash them
def print_flashing_message(title: str, key: str) -> None:
with open(os.path.join(args.build_dir, 'flasher_args.json')) as file:
with open(os.path.join(args.build_dir, 'flasher_args.json'), encoding='utf-8') as file:
flasher_args: Dict[str, Any] = json.load(file)
def flasher_path(f: Union[str, 'os.PathLike[str]']) -> str:
@@ -789,7 +789,7 @@ def expand_file_arguments(argv: List[Any]) -> List[Any]:
visited.add(rel_path)
try:
with open(rel_path, 'r') as f:
with open(rel_path, 'r', encoding='utf-8') as f:
for line in f:
expanded_args.extend(expand_args(shlex.split(line), os.path.dirname(rel_path), file_stack + [file_name]))
except IOError: