.pytool/LicenseCheck: Open files in utf-8

The LicenseCheck plugin currently fails if a file contains characters
outside the platform-dependent encoding returned from
locale.getencoding().

This change updates the encoding to utf-8 so the plugin is more
robust while continuing to support backward compatibility with the
ASCII range.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
This commit is contained in:
Michael Kubacki 2024-12-12 22:37:58 -05:00 committed by mergify[bot]
parent b8602d8fee
commit 260d36484d

View File

@ -70,7 +70,7 @@ class LicenseCheck(ICiBuildPlugin):
temp_diff_output = os.path.join (temp_path, 'diff.txt')
params = "diff --output={} --unified=0 origin/master HEAD".format(temp_diff_output)
RunCmd("git", params)
with open(temp_diff_output) as file:
with open(temp_diff_output, encoding='utf8') as file:
patch = file.read().strip().split("\n")
# Delete temp directory
if os.path.exists(temp_path):