mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-29783: Replace codecs.open() with io.open() (#599)
This commit is contained in:
parent
faa63d1e84
commit
272d888c7b
5 changed files with 18 additions and 39 deletions
|
@ -10,7 +10,7 @@
|
|||
"""
|
||||
|
||||
import re
|
||||
import codecs
|
||||
import io
|
||||
from os import path
|
||||
from time import asctime
|
||||
from pprint import pformat
|
||||
|
@ -254,11 +254,8 @@ class MiscNews(Directive):
|
|||
fpath = path.join(source_dir, fname)
|
||||
self.state.document.settings.record_dependencies.add(fpath)
|
||||
try:
|
||||
fp = codecs.open(fpath, encoding='utf-8')
|
||||
try:
|
||||
with io.open(fpath, encoding='utf-8') as fp:
|
||||
content = fp.read()
|
||||
finally:
|
||||
fp.close()
|
||||
except Exception:
|
||||
text = 'The NEWS file is not available.'
|
||||
node = nodes.strong(text, text)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue