Add explicit encoding when reading text from files

This commit is contained in:
Jonathan White 2025-11-23 19:11:19 -05:00 committed by Janek Bevendorff
parent 0f3def03b6
commit cb24df7aae

View file

@ -491,7 +491,7 @@ class Check(Command):
cmakelists = Path(cwd) / cmakelists cmakelists = Path(cwd) / cmakelists
if not cmakelists.is_file(): if not cmakelists.is_file():
raise Error('File not found: %s', cmakelists) raise Error('File not found: %s', cmakelists)
cmakelists_text = cmakelists.read_text() cmakelists_text = cmakelists.read_text("UTF-8")
major = re.search(r'^set\(KEEPASSXC_VERSION_MAJOR "(\d+)"\)$', cmakelists_text, re.MULTILINE).group(1) major = re.search(r'^set\(KEEPASSXC_VERSION_MAJOR "(\d+)"\)$', cmakelists_text, re.MULTILINE).group(1)
minor = re.search(r'^set\(KEEPASSXC_VERSION_MINOR "(\d+)"\)$', cmakelists_text, re.MULTILINE).group(1) minor = re.search(r'^set\(KEEPASSXC_VERSION_MINOR "(\d+)"\)$', cmakelists_text, re.MULTILINE).group(1)
patch = re.search(r'^set\(KEEPASSXC_VERSION_PATCH "(\d+)"\)$', cmakelists_text, re.MULTILINE).group(1) patch = re.search(r'^set\(KEEPASSXC_VERSION_PATCH "(\d+)"\)$', cmakelists_text, re.MULTILINE).group(1)
@ -507,7 +507,7 @@ class Check(Command):
if not changelog.is_file(): if not changelog.is_file():
raise Error('File not found: %s', changelog) raise Error('File not found: %s', changelog)
major, minor, patch = _split_version(version) major, minor, patch = _split_version(version)
if not re.search(rf'^## {major}\.{minor}\.{patch} \(.+?\)\n+', changelog.read_text(), re.MULTILINE): if not re.search(rf'^## {major}\.{minor}\.{patch} \(.+?\)\n+', changelog.read_text("UTF-8"), re.MULTILINE):
raise Error(f'{changelog} has not been updated to the "%s" release.', version) raise Error(f'{changelog} has not been updated to the "%s" release.', version)
@staticmethod @staticmethod
@ -576,7 +576,7 @@ class Tag(Command):
commit=True, yes=yes) commit=True, yes=yes)
changelog = re.search(rf'^## ({major}\.{minor}\.{patch} \(.*?\)\n\n+.+?)\n\n+## ', changelog = re.search(rf'^## ({major}\.{minor}\.{patch} \(.*?\)\n\n+.+?)\n\n+## ',
(Path(src_dir) / 'CHANGELOG.md').read_text(), re.MULTILINE | re.DOTALL) (Path(src_dir) / 'CHANGELOG.md').read_text("UTF-8"), re.MULTILINE | re.DOTALL)
if not changelog: if not changelog:
raise Error(f'No changelog entry found for version {version}.') raise Error(f'No changelog entry found for version {version}.')
changelog = 'Release ' + changelog.group(1) changelog = 'Release ' + changelog.group(1)