From f782b91dc4caedec19d14ea693b4ad3449050284 Mon Sep 17 00:00:00 2001 From: Michael Muller Date: Wed, 16 Dec 2020 10:03:32 -0500 Subject: [PATCH] Make config/presubmits.py use explicit encodings (#908) For some reason, our docker build image has started using a non-utf8 default encoding. Specify the encoding explicitly on python "open()" to override. Note that this might not entirely fix the build: it's possible that this problem may affect other portions of the build. --- config/presubmits.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/presubmits.py b/config/presubmits.py index 44fb511f4..fa3c9e675 100644 --- a/config/presubmits.py +++ b/config/presubmits.py @@ -65,7 +65,7 @@ class PresubmitCheck: for pattern in self.skipped_patterns: if pattern in file: return False - with open(file, "r") as f: + with open(file, "r", encoding='utf8') as f: file_content = f.read() matches = re.match(self.regex, file_content, re.DOTALL) if self.regex_type == FORBIDDEN: @@ -241,7 +241,7 @@ def verify_flyway_index(): # Remove the sequence numbers and compare against the index file contents. files = [filename[1] for filename in sorted(files)] - with open('db/src/main/resources/sql/flyway.txt') as index: + with open('db/src/main/resources/sql/flyway.txt', encoding='utf8') as index: indexed_files = index.read().splitlines() if files != indexed_files: unindexed = set(files) - set(indexed_files)