Skip to content

Commit b467001

Browse files
committed
FIX: workaround py2 unicode issues
9a8ed26 backported #7436 which fixed a warning about non explicitly encoded non-ascii characters. This 'just works' on python3, but we need to explicitly make the string with the unicode (¶ for the links) as unicode for py2. We can not use `from __future__ import unicode_literals` due to issues with shpinx expecting bytes (str) not unicode.
1 parent 51f53fb commit b467001

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

doc/sphinxext/gen_gallery.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# -*- coding: UTF-8 -*-
1+
# -*- coding: utf-8 -*-
22
import codecs
33
import os
44
import re
@@ -14,7 +14,7 @@
1414
multiimage = re.compile('(.*?)(_\d\d){1,2}')
1515

1616
# generate a thumbnail gallery of examples
17-
gallery_template = """\
17+
gallery_template = u"""\
1818
{{% extends "layout.html" %}}
1919
{{% set title = "Thumbnail gallery" %}}
2020
@@ -35,7 +35,7 @@
3535
{{% endblock %}}
3636
"""
3737

38-
header_template = """\
38+
header_template = u"""\
3939
<div class="section" id="{section}">
4040
<h4>
4141
{title}<a class="headerlink" href="#{section}" title="Permalink to this headline">¶</a>
@@ -48,7 +48,7 @@
4848
</figure>
4949
"""
5050

51-
toc_template = """\
51+
toc_template = u"""\
5252
<li><a class="reference internal" href="#{section}">{title}</a></li>"""
5353

5454

@@ -133,10 +133,10 @@ def gen_gallery(app, doctree):
133133
warnings.warn("No thumbnails were found in %s" % subdir)
134134

135135
# Close out the <div> opened up at the top of this loop
136-
rows.append("</div>")
136+
rows.append(u"</div>")
137137

138-
content = gallery_template.format(toc='\n'.join(toc_rows),
139-
gallery='\n'.join(rows))
138+
content = gallery_template.format(toc=u'\n'.join(toc_rows),
139+
gallery=u'\n'.join(rows))
140140

141141
# Only write out the file if the contents have actually changed.
142142
# Otherwise, this triggers a full rebuild of the docs

0 commit comments

Comments
 (0)