From 02fea029bfc5bfd64e43de9e810aef2dd3c8cb2c Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Tue, 11 Sep 2018 04:57:20 -0700 Subject: 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. --- sphinx/builders/htmlhelp.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sphinx/builders/htmlhelp.py') diff --git a/sphinx/builders/htmlhelp.py b/sphinx/builders/htmlhelp.py index 52600ca21..4d5172a8f 100644 --- a/sphinx/builders/htmlhelp.py +++ b/sphinx/builders/htmlhelp.py @@ -11,7 +11,6 @@ """ from __future__ import print_function -import codecs import os from os import path @@ -208,8 +207,8 @@ class HTMLHelpBuilder(StandaloneHTMLBuilder): def open_file(self, outdir, basename, mode='w'): # type: (unicode, unicode, unicode) -> IO # open a file with the correct encoding for the selected language - return codecs.open(path.join(outdir, basename), mode, # type: ignore - self.encoding, 'xmlcharrefreplace') + return open(path.join(outdir, basename), mode, # type: ignore + encoding=self.encoding, errors='xmlcharrefreplace') def update_page_context(self, pagename, templatename, ctx, event_arg): # type: (unicode, unicode, Dict, unicode) -> None -- cgit v1.2.1