python: Explicitly specify the encoding when opening files

This commit is contained in:
Eduardo Almeida
2023-05-21 17:31:39 +01:00
parent b20c657523
commit 20ae6fb2d0
12 changed files with 57 additions and 57 deletions

View File

@@ -155,7 +155,7 @@ def extract_linked_libraries(library_name: str, prefix: str) -> tuple:
linked_libs = []
# First discover which 3rd-party libraries are used by the current module
try:
with open(os.path.abspath(library_path), "rb") as f:
with open(os.path.abspath(library_path), "rb", encoding="utf-8") as f:
linked_libs = re.findall(b"\x00(lib.*?.%b)" % LIBRARY_EXTENSION.encode("utf-8"), f.read())
except Exception as e:
print("Failed to extract libraries used by {library} with exception:{exception}"