summaryrefslogtreecommitdiff
path: root/sphinx/pycode
diff options
context:
space:
mode:
authorDasIch <dasdasich@gmail.com>2010-05-24 18:25:20 +0200
committerDasIch <dasdasich@gmail.com>2010-05-24 18:25:20 +0200
commit3f3b30f45d6b4c31cfe5695f6874ea2a856e010d (patch)
tree1a3d5cd3f9243ab419ef032a6a83664e13666f4e /sphinx/pycode
parentb2982ffa71bd2b91ac6320d9ed3ddcb58639cb83 (diff)
downloadsphinx-3f3b30f45d6b4c31cfe5695f6874ea2a856e010d.tar.gz
don't assume strings to be byte strings
Diffstat (limited to 'sphinx/pycode')
-rw-r--r--sphinx/pycode/__init__.py3
-rw-r--r--sphinx/pycode/pgen2/literals.py2
2 files changed, 3 insertions, 2 deletions
diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py
index b8e2fded..cb9c0887 100644
--- a/sphinx/pycode/__init__.py
+++ b/sphinx/pycode/__init__.py
@@ -98,7 +98,8 @@ class AttrDocVisitor(nodes.NodeVisitor):
if not pnode or pnode.type not in (token.INDENT, token.DEDENT):
break
prefix = pnode.get_prefix()
- prefix = prefix.decode(self.encoding)
+ if not isinstance(prefix, unicode):
+ prefix = prefix.decode(self.encoding)
docstring = prepare_commentdoc(prefix)
self.add_docstring(node, docstring)
diff --git a/sphinx/pycode/pgen2/literals.py b/sphinx/pycode/pgen2/literals.py
index 31900291..d4893702 100644
--- a/sphinx/pycode/pgen2/literals.py
+++ b/sphinx/pycode/pgen2/literals.py
@@ -66,7 +66,7 @@ uni_escape_re = re.compile(r"\\(\'|\"|\\|[abfnrtv]|x.{0,2}|[0-7]{1,3}|"
def evalString(s, encoding=None):
regex = escape_re
repl = escape
- if encoding:
+ if encoding and not isinstance(s, unicode):
s = s.decode(encoding)
if s.startswith('u') or s.startswith('U'):
regex = uni_escape_re