8000 Better handling of unicode() sources (they are first encoded into UTF-8) · awesome-python/html5lib-python@48f65a3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 48f65a3

Browse files
committed
Better handling of unicode() sources (they are first encoded into UTF-8)
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40766
1 parent 9460bc9 commit 48f65a3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/inputstream.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ def openStream(self, source):
7676
if hasattr(source, 'read'):
7777
stream = source
7878
else:
79-
# Otherwise treat source as a string and convert to a file object
79+
# Otherwise treat source as a string and convert to a file object
80+
if isinstance(source, unicode):
81+
source = source.encode('utf-8')
8082
import cStringIO
8183
stream = cStringIO.StringIO(str(source))
8284
return stream

0 commit comments

Comments
 (0)
0