diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-06-16 06:59:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-16 06:59:01 (GMT) |
commit | 272d888c7b58aff5e1614e3b12e8198b92054835 (patch) | |
tree | 9514cfb06bace475f466f9c8222fb318e8966ee2 /Doc/tools | |
parent | faa63d1e84b273f75d94fe6e66f67a13e4c97f5e (diff) | |
download | cpython-272d888c7b58aff5e1614e3b12e8198b92054835.zip cpython-272d888c7b58aff5e1614e3b12e8198b92054835.tar.gz cpython-272d888c7b58aff5e1614e3b12e8198b92054835.tar.bz2 |
bpo-29783: Replace codecs.open() with io.open() (#599)
Diffstat (limited to 'Doc/tools')
-rw-r--r-- | Doc/tools/extensions/pyspecific.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index 1b91259..461e7a2 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -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) |