From 3f3b30f45d6b4c31cfe5695f6874ea2a856e010d Mon Sep 17 00:00:00 2001 From: DasIch Date: Mon, 24 May 2010 18:25:20 +0200 Subject: don't assume strings to be byte strings --- sphinx/pycode/__init__.py | 3 ++- sphinx/pycode/pgen2/literals.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'sphinx') 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 -- cgit v1.2.1