From ee41bf4fadb7f907938a1822bb772e9cde01dff3 Mon Sep 17 00:00:00 2001 From: actionless Date: Fri, 30 Aug 2024 00:24:55 +0200 Subject: [PATCH] fix(install_cli: manual_package_selection): force encoding when writing and reading temp file (fixes #836) --- pikaur/install_cli.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pikaur/install_cli.py b/pikaur/install_cli.py index 2e5062a6a..f526053a1 100644 --- a/pikaur/install_cli.py +++ b/pikaur/install_cli.py @@ -11,7 +11,13 @@ from .args import parse_args, reconstruct_args from .build import PackageBuild, PkgbuildChanged, clone_aur_repos -from .config import DECORATION, DiffPagerValues, PikaurConfig, UsingDynamicUsers +from .config import ( + DECORATION, + DEFAULT_CONFIG_ENCODING, + DiffPagerValues, + PikaurConfig, + UsingDynamicUsers, +) from .conflicts import find_aur_conflicts from .exceptions import ( BuildError, @@ -509,11 +515,11 @@ def parse_pkg_names(text: str) -> set[str]: ) pkg_names_before = parse_pkg_names(text_before) with NamedTemporaryFile() as tmp_file: - with open_file(tmp_file.name, "w") as write_file: + with open_file(tmp_file.name, "w", encoding=DEFAULT_CONFIG_ENCODING) as write_file: write_file.write(text_before) chown_to_current(Path(tmp_file.name)) edit_file(tmp_file.name) - with open_file(tmp_file.name, "r") as read_file: + with open_file(tmp_file.name, "r", encoding=DEFAULT_CONFIG_ENCODING) as read_file: selected_packages = parse_pkg_names(read_file.read()) list_diff = selected_packages.difference(pkg_names_before)