summaryrefslogtreecommitdiff
path: root/sphinx/builders/changes.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/builders/changes.py')
-rw-r--r--sphinx/builders/changes.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/sphinx/builders/changes.py b/sphinx/builders/changes.py
index 3e351e6cb..22fcab869 100644
--- a/sphinx/builders/changes.py
+++ b/sphinx/builders/changes.py
@@ -11,7 +11,6 @@
import codecs
from os import path
-from cgi import escape
from sphinx import package_dir
from sphinx.util import copy_static_entry
@@ -20,6 +19,7 @@ from sphinx.theming import Theme
from sphinx.builders import Builder
from sphinx.util.osutil import ensuredir, os_path
from sphinx.util.console import bold
+from sphinx.util.pycompat import htmlescape
class ChangesBuilder(Builder):
@@ -115,7 +115,7 @@ class ChangesBuilder(Builder):
'.. deprecated:: %s' % version]
def hl(no, line):
- line = '<a name="L%s"> </a>' % no + escape(line)
+ line = '<a name="L%s"> </a>' % no + htmlescape(line)
for x in hltext:
if x in line:
line = '<span class="hl">%s</span>' % line
@@ -125,7 +125,10 @@ class ChangesBuilder(Builder):
self.info(bold('copying source files...'))
for docname in self.env.all_docs:
f = codecs.open(self.env.doc2path(docname), 'r', 'latin1')
- lines = f.readlines()
+ try:
+ lines = f.readlines()
+ finally:
+ f.close()
targetfn = path.join(self.outdir, 'rst', os_path(docname)) + '.html'
ensuredir(path.dirname(targetfn))
f = codecs.open(targetfn, 'w', 'latin1')
@@ -148,7 +151,7 @@ class ChangesBuilder(Builder):
self.outdir, self)
def hl(self, text, version):
- text = escape(text)
+ text = htmlescape(text)
for directive in ['versionchanged', 'versionadded', 'deprecated']:
text = text.replace('.. %s:: %s' % (directive, version),
'<b>.. %s:: %s</b>' % (directive, version))