summaryrefslogtreecommitdiff
path: root/sphinx/util/pycompat.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/util/pycompat.py')
-rw-r--r--sphinx/util/pycompat.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py
index a95c9332..375f6920 100644
--- a/sphinx/util/pycompat.py
+++ b/sphinx/util/pycompat.py
@@ -25,6 +25,8 @@ if sys.version_info >= (3, 0):
bytes = bytes
# prefix for Unicode strings
u = ''
+ # StringIO/BytesIO classes
+ from io import StringIO, BytesIO, TextIOWrapper
# support for running 2to3 over config files
def convert_with_2to3(filepath):
from lib2to3.refactor import RefactoringTool, get_fixers_from_package
@@ -48,8 +50,12 @@ else:
b = str
bytes = str
u = 'u'
+ from StringIO import StringIO
+ BytesIO = StringIO
# no need to refactor on 2.x versions
convert_with_2to3 = None
+ def TextIOWrapper(stream, encoding):
+ return codecs.lookup(encoding or 'ascii')[2](stream)
# ------------------------------------------------------------------------------