Skip to content

Commit

Permalink
Make sure doc writer doesn't mangle encodings on non-utf8 systems lik…
Browse files Browse the repository at this point in the history
…e Windows.
  • Loading branch information
KubaO committed Jun 20, 2023
1 parent 5ddcbc8 commit cac9083
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hpy/tools/autogen/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def write(self, root):
if not self.BEGIN_MARKER or not self.END_MARKER:
raise RuntimeError("missing BEGIN_MARKER or END_MARKER")
n_begin = len(self.BEGIN_MARKER)
with root.join(self.PATH).open('r') as f:
with root.join(self.PATH).open('r', encoding='utf-8') as f:
content = f.read()
start = content.find(self.BEGIN_MARKER)
if start < 0:
Expand All @@ -75,7 +75,7 @@ def write(self, root):
raise RuntimeError(f'end marker "{self.END_MARKER}" not found in'
f'file {self.PATH}')
new_content = self.generate(content[(start+n_begin):end])
with root.join(self.PATH).open('w') as f:
with root.join(self.PATH).open('w', encoding='utf-8') as f:
f.write(content[:start + n_begin] + new_content + content[end:])


Expand Down

0 comments on commit cac9083

Please sign in to comment.