Commits

Georg Brandl committed 1ed346c

Move the "b" function to pycompat.

  • Participants
  • Parent commits 2adbfb6

Comments (0)

Files changed (3)

sphinx/util/osutil.py

 
 import os
 import re
+import sys
 import time
 import errno
 import shutil
-import sys
 from os import path
 
 # Errnos that we need.

sphinx/util/pycompat.py

     base_exception = Exception
 
 
+# the ubiquitous "bytes" helper function
+if sys.version_info > (3, 0):
+    def b(s):
+        return s.encode('utf-8')
+else:
+    b = str
+
+
 try:
     any = any
     all = all

tests/test_markup.py

 """
 
 import re
-import sys
 
 from util import *
 
 from docutils.parsers import rst
 
 from sphinx.util import texescape
+from sphinx.util.pycompat import b
 from sphinx.writers.html import HTMLWriter, SmartyPantsHTMLTranslator
 from sphinx.writers.latex import LaTeXWriter, LaTeXTranslator
 
-if sys.version_info > (3, 0):
-    def b(s):
-        return s.encode('utf-8')
-else:
-    b = str
-
 def setup_module():
     global app, settings, parser
     texescape.init()  # otherwise done by the latex builder