diff options
author | Michael Kubacki <michael.kubacki@microsoft.com> | 2024-12-12 22:54:03 -0500 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-12-19 00:19:13 +0000 |
commit | 7e7492fa12fa924e4e3699ecf1e456e1f641dea4 (patch) | |
tree | a153ee13d7f57a5c3447d896a515824cfea11ea9 | |
parent | 260d36484dbf7eec0a05dafff253692318125ac5 (diff) | |
download | edk2-7e7492fa12fa924e4e3699ecf1e456e1f641dea4.tar.gz |
.pytool/EccCheck: Open files in utf-8
The EccCheck 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>
-rw-r--r-- | .pytool/Plugin/EccCheck/EccCheck.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/.pytool/Plugin/EccCheck/EccCheck.py b/.pytool/Plugin/EccCheck/EccCheck.py index 0002143f1a..57f07e957e 100644 --- a/.pytool/Plugin/EccCheck/EccCheck.py +++ b/.pytool/Plugin/EccCheck/EccCheck.py @@ -144,7 +144,7 @@ class EccCheck(ICiBuildPlugin): #
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')
return patch
@@ -163,7 +163,7 @@ class EccCheck(ICiBuildPlugin): params = "diff --output={} --diff-filter=dr --name-status origin/master HEAD".format(temp_diff_output)
RunCmd("git", params)
dir_list = []
- with open(temp_diff_output) as file:
+ with open(temp_diff_output, encoding='utf8') as file:
dir_list = file.read().strip().split('\n')
modify_dir_list = []
@@ -271,7 +271,7 @@ class EccCheck(ICiBuildPlugin): modify_file_path = os.path.join(temp_path, modify_file)
if not os.path.exists (modify_file_path):
return comment_range
- with open(modify_file_path) as f:
+ with open(modify_file_path, encoding='utf8') as f:
line_no = 1
Start = False
for line in f:
@@ -319,7 +319,7 @@ class EccCheck(ICiBuildPlugin): row_lines = []
ignore_error_code = self.GetIgnoreErrorCode()
if os.path.exists(ecc_csv):
- with open(ecc_csv) as csv_file:
+ with open(ecc_csv, encoding='utf8') as csv_file:
reader = csv.reader(csv_file)
for row in reader:
for modify_file in ecc_diff_range:
|