We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b21ed70 commit 0eacde6Copy full SHA for 0eacde6
html5lib/inputstream.py
@@ -195,8 +195,12 @@ def openStream(self, source):
195
if isinstance(source, unicode):
196
source = source.encode('utf-8')
197
self.charEncoding = ("utf-8", "certain")
198
- import cStringIO
199
- stream = cStringIO.StringIO(str(source))
+ try:
+ from io import BytesIO
200
+ except:
201
+ # 2to3 converts this line to: from io import StringIO
202
+ from cStringIO import StringIO as BytesIO
203
+ stream = BytesIO(source)
204
205
if (not(hasattr(stream, "tell") and hasattr(stream, "seek")) or
206
stream is sys.stdin):
0 commit comments