소스 검색

Specify encoding when opening text files

When opening a text file it is important to specify encoding='utf-8'
since otherwise the behavior will depend on your system locale. This
change fixes various encoding omissions in PRESUBMIT.py files, found
when presubmits were run when uploading crrev.com/c/4290775.

Bug: 1418846
Change-Id: Ief5f6d6bb749de95bc4071055492e6c9c6b6c56d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4292516
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Bruce Dawson 2 년 전
부모
커밋
424814829a
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      PRESUBMIT.py

+ 2 - 2
PRESUBMIT.py

@@ -49,12 +49,12 @@ def CheckPylint(input_api, output_api):
   ]
   files_to_skip = list(input_api.DEFAULT_FILES_TO_SKIP)
   if os.path.exists('.gitignore'):
-    with open('.gitignore') as fh:
+    with open('.gitignore', encoding='utf-8') as fh:
       lines = [l.strip() for l in fh.readlines()]
       files_to_skip.extend([fnmatch.translate(l) for l in lines if
                          l and not l.startswith('#')])
   if os.path.exists('.git/info/exclude'):
-    with open('.git/info/exclude') as fh:
+    with open('.git/info/exclude', encoding='utf-8') as fh:
       lines = [l.strip() for l in fh.readlines()]
       files_to_skip.extend([fnmatch.translate(l) for l in lines if
                          l and not l.startswith('#')])