Bug 1918249 - Fix `mach lint` linting prefs JS files on Windows by forcing UTF-8. r=ahal

Prefs files in general are allowed to not be UTF-8, but all the prefs
files in tree are UTF-8, so we can lint them with that assumption.

Differential Revision: https://phabricator.services.mozilla.com/D221878
This commit is contained in:
Nick Alexander 2024-09-13 17:00:04 +00:00
Родитель d380299917
Коммит 97967b0ece
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -33,7 +33,7 @@ def get_names(pref_list_filename):
# pattern does not happen in 'name', so it's fine to ignore these.
# We also want to evaluate all branches of #ifdefs for pref names, so we
# ignore anything else preprocessor related.
file = open(pref_list_filename).read().replace("@", "")
file = open(pref_list_filename, encoding="utf-8").read().replace("@", "")
try:
pref_list = yaml.safe_load(file)
except (IOError, ValueError) as e:
@ -77,7 +77,7 @@ def check_value_for_pref(some_pref, some_value, path):
# matching to load in prefs.
def read_prefs(path):
prefs = []
with open(path) as source:
with open(path, encoding="utf-8") as source:
for lineno, line in enumerate(source, start=1):
match = PATTERN.match(line)
if match: