diff --git a/doc/conf.py b/doc/conf.py
index 03ca7061a926..ceb41bd84aa7 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -174,10 +174,10 @@
# Additional stuff for the LaTeX preamble.
latex_preamble = """
- \usepackage{amsmath}
- \usepackage{amsfonts}
- \usepackage{amssymb}
- \usepackage{txfonts}
+ \\usepackage{amsmath}
+ \\usepackage{amsfonts}
+ \\usepackage{amssymb}
+ \\usepackage{txfonts}
"""
# Documents to append as an appendix to all manuals.
diff --git a/doc/make.py b/doc/make.py
index 7df050d13ad4..8e37ec7f6e36 100755
--- a/doc/make.py
+++ b/doc/make.py
@@ -89,20 +89,20 @@ def copytree(src, dst, symlinks=False, ignore=None):
copy2(srcname, dstname)
# catch the Error from the recursive copytree so that we can
# continue with other files
- except Error, err:
+ except Error as err:
errors.extend(err.args[0])
- except EnvironmentError, why:
+ except EnvironmentError as why:
errors.append((srcname, dstname, str(why)))
try:
copystat(src, dst)
- except OSError, why:
+ except OSError as why:
if WindowsError is not None and isinstance(why, WindowsError):
# Copying file access times may fail on Windows
pass
else:
errors.extend((src, dst, str(why)))
if errors:
- raise Error, errors
+ raise Error(errors)
### End compatibility block for pre-v2.6 ###
diff --git a/doc/sphinxext/gen_gallery.py b/doc/sphinxext/gen_gallery.py
index 609829262933..0e2eb25c09f5 100644
--- a/doc/sphinxext/gen_gallery.py
+++ b/doc/sphinxext/gen_gallery.py
@@ -121,18 +121,18 @@ def gen_gallery(app, doctree):
gallery_path = os.path.join(app.builder.srcdir, '_templates', 'gallery.html')
if os.path.exists(gallery_path):
- fh = file(gallery_path, 'r')
+ fh = open(gallery_path, 'r')
regenerate = fh.read() != content
fh.close()
else:
regenerate = True
if regenerate:
- fh = file(gallery_path, 'w')
+ fh = open(gallery_path, 'w')
fh.write(content)
fh.close()
for key in app.builder.status_iterator(
- thumbnails.iterkeys(), "generating thumbnails... ",
+ iter(thumbnails.keys()), "generating thumbnails... ",
length=len(thumbnails)):
image.thumbnail(key, thumbnails[key], 0.3)
diff --git a/doc/sphinxext/gen_rst.py b/doc/sphinxext/gen_rst.py
index e8135bf4abdb..a251917fe490 100644
--- a/doc/sphinxext/gen_rst.py
+++ b/doc/sphinxext/gen_rst.py
@@ -2,6 +2,7 @@
generate the rst files for the examples by iterating over the pylab examples
"""
from __future__ import print_function
+import io
import os, glob
import os
@@ -37,15 +38,18 @@ def generate_example_rst(app):
continue
fullpath = os.path.join(root,fname)
- contents = file(fullpath).read()
+ if sys.version_info[0] >= 3:
+ contents = io.open(fullpath, encoding='utf8').read()
+ else:
+ contents = io.open(fullpath).read()
# indent
relpath = os.path.split(root)[-1]
datad.setdefault(relpath, []).append((fullpath, fname, contents))
- subdirs = datad.keys()
+ subdirs = list(datad.keys())
subdirs.sort()
- fhindex = file(os.path.join(exampledir, 'index.rst'), 'w')
+ fhindex = open(os.path.join(exampledir, 'index.rst'), 'w')
fhindex.write("""\
.. _examples-index:
@@ -77,7 +81,7 @@ def generate_example_rst(app):
os.makedirs(outputdir)
subdirIndexFile = os.path.join(rstdir, 'index.rst')
- fhsubdirIndex = file(subdirIndexFile, 'w')
+ fhsubdirIndex = open(subdirIndexFile, 'w')
fhindex.write(' %s/index.rst\n\n'%subdir)
fhsubdirIndex.write("""\
@@ -122,14 +126,17 @@ def generate_example_rst(app):
) and
not noplot_regex.search(contents))
if not do_plot:
- fhstatic = file(outputfile, 'w')
+ fhstatic = open(outputfile, 'w')
fhstatic.write(contents)
fhstatic.close()
if not out_of_date(fullpath, outrstfile):
continue
- fh = file(outrstfile, 'w')
+ if sys.version_info[0] >= 3:
+ fh = io.open(outrstfile, 'w', encoding='utf8')
+ else:
+ fh = io.open(outrstfile, 'w')
fh.write('.. _%s-%s:\n\n'%(subdir, basename))
title = '%s example code: %s'%(subdir, fname)
#title = ' %s example code: %s'%(thumbfile, subdir, fname)
diff --git a/lib/matplotlib/sphinxext/mathmpl.py b/lib/matplotlib/sphinxext/mathmpl.py
index 0c126a66b02e..4cbadf092828 100644
--- a/lib/matplotlib/sphinxext/mathmpl.py
+++ b/lib/matplotlib/sphinxext/mathmpl.py
@@ -65,7 +65,7 @@ def latex2png(latex, filename, fontset='cm'):
def latex2html(node, source):
inline = isinstance(node.parent, nodes.TextElement)
latex = node['latex']
- name = 'math-%s' % md5(latex).hexdigest()[-10:]
+ name = 'math-%s' % md5(latex.encode()).hexdigest()[-10:]
destdir = os.path.join(setup.app.builder.outdir, '_images', 'mathmpl')
if not os.path.exists(destdir):
diff --git a/lib/matplotlib/sphinxext/plot_directive.py b/lib/matplotlib/sphinxext/plot_directive.py
index ac96d5fa3568..e0a6c53709fb 100644
--- a/lib/matplotlib/sphinxext/plot_directive.py
+++ b/lib/matplotlib/sphinxext/plot_directive.py
@@ -125,8 +125,8 @@
"""
from __future__ import print_function
-import sys, os, glob, shutil, imp, warnings, cStringIO, re, textwrap, \
- traceback, exceptions
+import sys, os, glob, shutil, imp, warnings, cStringIO, re, textwrap
+import traceback
from docutils.parsers.rst import directives
from docutils import nodes
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: