Skip to content

Commit 77d3d0e

Browse files
committed
doc: Fix underscore fixup on Python 3 in non-UTF-8 locale
1 parent 8ab3d92 commit 77d3d0e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

doc/jekyll_fix.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
}
3030
REWRITE_EXTENSIONS = set(['.html', '.js'])
3131

32+
from io import open
3233
import os
3334
from sphinx.util.console import bold
3435

@@ -42,11 +43,11 @@ def remove_directory_underscores(app, exception):
4243
_, ext = os.path.splitext(filename)
4344
if ext in REWRITE_EXTENSIONS:
4445
path = os.path.join(dirpath, filename)
45-
with open(path) as fh:
46+
with open(path, encoding='utf-8') as fh:
4647
contents = fh.read()
4748
for old, new in DIRS.items():
4849
contents = contents.replace(old + '/', new + '/')
49-
with open(path, 'w') as fh:
50+
with open(path, 'w', encoding='utf-8') as fh:
5051
fh.write(contents)
5152
# Move directory contents
5253
for old, new in DIRS.items():

0 commit comments

Comments
 (0)