diff --git a/html5lib/inputstream.py b/html5lib/inputstream.py
index 159901be..7eab174a 100644
--- a/html5lib/inputstream.py
+++ b/html5lib/inputstream.py
@@ -3,7 +3,6 @@
import codecs
import re
-import sys
from .constants import EOF, spaceCharacters, asciiLetters, asciiUppercase
from .constants import encodings, ReparseException
@@ -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):
@@ -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