Commits

Mike Bayer committed 409cdaf

- some py3k compatibility

Comments (0)

Files changed (1)

doc/build/builder/viewsource.py

 from docutils.statemachine import StringList
 from sphinx.environment import NoUri
 
+import sys
+
+py2k = sys.version_info < (3, 0)
+if py2k:
+    text_type = unicode
+else:
+    text_type = str
+
 def view_source(name, rawtext, text, lineno, inliner,
                       options={}, content=[]):
 
     analyzer = ModuleAnalyzer.for_file(pathname, modname)
     # copied from viewcode
     analyzer.find_tags()
-    if not isinstance(analyzer.code, unicode):
+    if not isinstance(analyzer.code, text_type):
         code = analyzer.code.decode(analyzer.encoding)
     else:
         code = analyzer.code