1. Doug Hellmann
  2. sphinx

Commits

DasIch  committed 3bc4f0f

don't assume strings to be byte strings

  • Participants
  • Parent commits 9be2b52
  • Branches default

Comments (0)

Files changed (2)

File sphinx/pycode/__init__.py

View file
  • Ignore whitespace
             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)
 

File sphinx/pycode/pgen2/literals.py

View file
  • Ignore whitespace
 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