diff options
author | Georg Brandl <georg@python.org> | 2012-03-10 21:50:06 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2012-03-10 21:50:06 +0100 |
commit | a7204e1c13f59373bc3a8e1429dbaf88f25c71a7 (patch) | |
tree | 83314b920e475b8ee70a8215698b7c94ce6ce709 | |
parent | 5bd456fa6c10b27a00ea6afbf80daa4ed6f3c107 (diff) | |
download | sphinx-a7204e1c13f59373bc3a8e1429dbaf88f25c71a7.tar.gz |
Fix force_decode() to work on Python 3.1.1.3
-rw-r--r-- | sphinx/builders/qthelp.py | 9 | ||||
-rw-r--r-- | sphinx/util/__init__.py | 3 |
2 files changed, 6 insertions, 6 deletions
diff --git a/sphinx/builders/qthelp.py b/sphinx/builders/qthelp.py index 6a40005f..5e5deaf1 100644 --- a/sphinx/builders/qthelp.py +++ b/sphinx/builders/qthelp.py @@ -137,7 +137,6 @@ class QtHelpBuilder(StandaloneHTMLBuilder): new_sections = [] for section in sections: if not isinstance(section, unicode): - # XXX is this really necessary? new_sections.append(force_decode(section, None)) else: new_sections.append(section) @@ -222,14 +221,14 @@ class QtHelpBuilder(StandaloneHTMLBuilder): return True def write_toc(self, node, indentlevel=4): + # XXX this should return a Unicode string, not a bytestring parts = [] if self.isdocnode(node): refnode = node.children[0][0] link = refnode['refuri'] - title = htmlescape(refnode.astext()).replace('"','"') - item = '<section title="%(title)s" ref="%(ref)s">' % { - 'title': title, - 'ref': link} + title = htmlescape(refnode.astext()).replace('"', '"') + item = '<section title="%(title)s" ref="%(ref)s">' % \ + {'title': title, 'ref': link} parts.append(' '*4*indentlevel + item) for subnode in node.children[1]: parts.extend(self.write_toc(subnode, indentlevel+1)) diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 0d67da82..6cb83aec 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -28,6 +28,7 @@ import jinja2 import sphinx from sphinx.errors import PycodeError +from sphinx.util.pycompat import bytes # import other utilities; partly for backwards compatibility, so don't # prune unused ones indiscriminately @@ -310,7 +311,7 @@ def parselinenos(spec, total): def force_decode(string, encoding): """Forcibly get a unicode string out of a bytestring.""" - if isinstance(string, str): + if isinstance(string, bytes): if encoding: string = string.decode(encoding) else: |