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

Commite674941

Browse files
jcarlosgarciasegoviagsnedders
authored andcommitted
Google Code Issue 215: Properly detect seekable streams
Removes the hack that tests for sys.stdin to determine if the streamis seekable (it has tell() and seek() but it is not seekable) byactually calling tell() and seek().This also removes the wrapping in HTMLUnicodeInputStream, where wedo not need the ability to seek.
1 parent52c37b6 commite674941

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

‎html5lib/inputstream.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
importcodecs
55
importre
6-
importsys
76

87
from .constantsimportEOF,spaceCharacters,asciiLetters,asciiUppercase
98
from .constantsimportencodings,ReparseException
@@ -202,12 +201,6 @@ def openStream(self, source):
202201
else:
203202
stream=StringIO(source)
204203

205-
if (# not isinstance(stream, BufferedIOBase) and
206-
not(hasattr(stream,"tell")and
207-
hasattr(stream,"seek"))or
208-
streamissys.stdin):
209-
stream=BufferedStream(stream)
210-
211204
returnstream
212205

213206
def_position(self,offset):
@@ -437,8 +430,9 @@ def openStream(self, source):
437430
else:
438431
stream=BytesIO(source)
439432

440-
if (not(hasattr(stream,"tell")andhasattr(stream,"seek"))or
441-
streamissys.stdin):
433+
try:
434+
stream.seek(stream.tell())
435+
except:
442436
stream=BufferedStream(stream)
443437

444438
returnstream

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp