Skip to content

Commit 3c821db

Browse files
committed
Ensure text files are opened as UTF-8
1 parent fe93434 commit 3c821db

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

commands/preprocess_cssless.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030

3131
def preprocess_html_merge_cssless(src_path, dst_path):
32-
with open(src_path, 'r') as a_file:
32+
with open(src_path, 'r', encoding='utf-8') as a_file:
3333
content = a_file.read()
3434
parser = etree.HTMLParser(encoding='utf-8')
3535
stripped = content.strip()

gadgets/replace_tests_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ def main():
4646

4747
for path in paths:
4848
print('Processing {0}'.format(path))
49-
with open(path, 'r') as file:
49+
with open(path, 'r', encoding='utf-8') as file:
5050
text = file.read()
5151

5252
# TODO user proper XML parser, not this hack
5353
text = re.sub('<link rel="selenium.base" href="(.*)" />',
5454
'<link rel="selenium.base" href="' + args.url + '" />', text)
5555

56-
with open(path, 'w') as file:
56+
with open(path, 'w', encoding='utf-8') as file:
5757
file.write(text)
5858

5959
if __name__ == '__main__':

gadgets/sync_tests_mwiki.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def sync_single_page(page, direction, dest_root):
7171
if direction == SYNC_DIRECTION_UPLOAD:
7272
if not os.path.exists(dest_path):
7373
return
74-
with open(dest_path, 'r') as file:
74+
with open(dest_path, 'r', encoding='utf-8') as file:
7575
new_text = file.read()
7676
if fix_whitespace(text) != fix_whitespace(new_text):
7777
page.put(new_text, 'sync with git')
@@ -82,7 +82,7 @@ def sync_single_page(page, direction, dest_root):
8282
if not os.path.exists(dest_dir):
8383
os.makedirs(dest_dir)
8484

85-
with open(dest_path, 'w') as file:
85+
with open(dest_path, 'w', encoding='utf-8') as file:
8686
file.write(fix_whitespace(text))
8787
print('Downloaded {0}'.format(dest_path))
8888

tests/test_preprocess_cssless.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ def test_preprocess_html_merge_cssless(self):
4343

4444
preprocess_html_merge_cssless(src_path, dst_path)
4545

46-
with open(dst_path, 'r') as a_file:
46+
with open(dst_path, 'r', encoding='utf-8') as a_file:
4747
test = a_file.read()
4848

49-
with open(expected_path, 'r') as a_file:
49+
with open(expected_path, 'r', encoding='utf-8') as a_file:
5050
expected = a_file.read()
5151

5252
self.assertEqual(test, expected)
@@ -63,10 +63,10 @@ def test_preprocess_html_merge_cssless2(self):
6363

6464
preprocess_html_merge_cssless(src_path, dst_path)
6565

66-
with open(dst_path, 'r') as a_file:
66+
with open(dst_path, 'r', encoding='utf-8') as a_file:
6767
test = a_file.read()
6868

69-
with open(expected_path, 'r') as a_file:
69+
with open(expected_path, 'r', encoding='utf-8') as a_file:
7070
expected = a_file.read()
7171

7272
self.assertEqual(test, expected)

0 commit comments

Comments
 (0)