Skip to content

Commit 6b136f9

Browse files
authored
Replace codecs.open() with open() (#13655)
1 parent a2f7b41 commit 6b136f9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

sphinx/builders/gettext.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
import codecs
65
import operator
76
import os
87
import os.path
@@ -212,7 +211,7 @@ def should_write(filepath: Path, new_content: str) -> bool:
212211
if not filepath.exists():
213212
return True
214213
try:
215-
with codecs.open(str(filepath), encoding='utf-8') as oldpot:
214+
with open(filepath, encoding='utf-8') as oldpot:
216215
old_content = oldpot.read()
217216
old_header_index = old_content.index('"POT-Creation-Date:')
218217
new_header_index = new_content.index('"POT-Creation-Date:')
@@ -275,7 +274,7 @@ def _extract_from_template(self) -> None:
275274
self.config.verbosity,
276275
):
277276
try:
278-
with codecs.open(template, encoding='utf-8') as f:
277+
with open(template, encoding='utf-8') as f:
279278
context = f.read()
280279
for line, _meth, msg in extract_translations(context):
281280
origin = MsgOrigin(source=template, line=line)
@@ -326,7 +325,7 @@ def finish(self) -> None:
326325

327326
pofn = self.outdir / f'{textdomain}.pot'
328327
if should_write(pofn, content):
329-
with codecs.open(str(pofn), 'w', encoding='utf-8') as pofile:
328+
with open(pofn, 'w', encoding='utf-8') as pofile:
330329
pofile.write(content)
331330

332331

0 commit comments

Comments
 (0)