Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0eacde6

Browse files
committed
General StringIO for python 2 and 3
1 parentb21ed70 commit0eacde6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎html5lib/inputstream.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,12 @@ def openStream(self, source):
195195
ifisinstance(source,unicode):
196196
source=source.encode('utf-8')
197197
self.charEncoding= ("utf-8","certain")
198-
importcStringIO
199-
stream=cStringIO.StringIO(str(source))
198+
try:
199+
fromioimportBytesIO
200+
except:
201+
# 2to3 converts this line to: from io import StringIO
202+
fromcStringIOimportStringIOasBytesIO
203+
stream=BytesIO(source)
200204

201205
if (not(hasattr(stream,"tell")andhasattr(stream,"seek"))or
202206
streamissys.stdin):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp