8000 Google Code Issue 215: Properly detect seekable streams by gsnedders · Pull Request #35 · html5lib/html5lib-python · GitHub
[go: up one dir, main page]

Skip to content

Google Code Issue 215: Properly detect seekable streams #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions html5lib/inputstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import codecs
import re
import sys

from .constants import EOF, spaceCharacters, asciiLetters, asciiUppercase
from .constants import encodings, ReparseException
Expand Down Expand Up @@ -202,12 +201,6 @@ def openStream(self, source):
else:
stream = StringIO(source)

if ( # not isinstance(stream, BufferedIOBase) and
not(hasattr(stream, "tell") and
hasattr(stream, "seek")) or
stream is sys.stdin):
stream = BufferedStream(stream)

return stream

def _position(self, offset):
Expand Down Expand Up @@ -437,8 +430,9 @@ def openStream(self, source):
else:
stream = BytesIO(source)

if (not(hasattr(stream, "tell") and hasattr(stream, "seek")) or
stream is sys.stdin):
try:
stream.seek(stream.tell())
except:
stream = BufferedStream(stream)

return stream
Expand Down
0