summaryrefslogtreecommitdiff
path: root/sphinx/util
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2011-09-19 09:03:07 +0200
committerGeorg Brandl <georg@python.org>2011-09-19 09:03:07 +0200
commit0a9c4d641f1c1f9f6e9ec0ec1fc10f22c4e57e99 (patch)
treea8f2d9cbefc14fb1c01e31fcc22833f8e08c0bc0 /sphinx/util
parentc1e0adeed0bb2288a147e922e8a88f5663a69f48 (diff)
downloadsphinx-0a9c4d641f1c1f9f6e9ec0ec1fc10f22c4e57e99.tar.gz
Fix #705: read module source in ModuleAnalyzer in binary mode, decode afterwards.
Diffstat (limited to 'sphinx/util')
-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)
# ------------------------------------------------------------------------------