diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2018-09-11 14:57:20 +0300 |
---|---|---|
committer | Jon Dufresne <jon.dufresne@gmail.com> | 2018-09-11 15:45:36 +0300 |
commit | 02fea029bfc5bfd64e43de9e810aef2dd3c8cb2c (patch) | |
tree | 8460d233e013fe774e8e9d5a2cc3e3ef2392a37d /sphinx/util/fileutil.py | |
parent | 844a3a5c226ff8891a1ce139f10ac92157c75da5 (diff) |
Prefer builtin open() over io.open() and codecs.open()
In Python3, the functions io.open() is an alias of the builtin open()
and codecs.open() is functionally equivalent. To reduce indirection,
number of imports, and number of patterns, always prefer the builtin.
https://docs.python.org/3/library/io.html#high-level-module-interface
> io.open()
>
> This is an alias for the builtin open() function.
Diffstat (limited to 'sphinx/util/fileutil.py')
-rw-r--r-- | sphinx/util/fileutil.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/sphinx/util/fileutil.py b/sphinx/util/fileutil.py index fcbc8abe6..85b6d4f47 100644 --- a/sphinx/util/fileutil.py +++ b/sphinx/util/fileutil.py @@ -10,7 +10,6 @@ """ from __future__ import absolute_import -import codecs import os import posixpath @@ -49,10 +48,10 @@ def copy_asset_file(source, destination, context=None, renderer=None): from sphinx.util.template import SphinxRenderer renderer = SphinxRenderer() - with codecs.open(source, 'r', encoding='utf-8') as fsrc: # type: ignore + with open(source, 'r', encoding='utf-8') as fsrc: # type: ignore if destination.lower().endswith('_t'): destination = destination[:-2] - with codecs.open(destination, 'w', encoding='utf-8') as fdst: # type: ignore + with open(destination, 'w', encoding='utf-8') as fdst: # type: ignore fdst.write(renderer.render_string(fsrc.read(), context)) else: copyfile(source, destination) |