File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -413,8 +413,10 @@ def peek(self, n):
413413 if self .fileobj is None :
414414 return b''
415415 try :
416- # 1024 is the same buffering heuristic used in read()
417- self ._read (max (n , 1024 ))
416+ # Ensure that we don't return b"" if we haven't reached EOF.
417+ while self .extrasize == 0 :
418+ # 1024 is the same buffering heuristic used in read()
419+ self ._read (max (n , 1024 ))
418420 except EOFError :
419421 pass
420422 offset = self .offset - self .extrastart
Original file line number Diff line number Diff line change @@ -81,8 +81,8 @@ Library
8181 constructor, objects in the ipaddress module no longer implement __index__
8282 (they still implement __int__ as appropriate)
8383
84- - Issue #15546: Fix handling of pathological input data in the read1 () method of
85- the BZ2File, GzipFile and LZMAFile classes.
84+ - Issue #15546: Fix handling of pathological input data in the peek () and
85+ read1() methods of the BZ2File, GzipFile and LZMAFile classes.
8686
8787- Issue #13052: Fix IDLE crashing when replace string in Search/Replace dialog
8888 ended with '\'. Patch by Roger Serwy.
You can’t perform that action at this time.
0 commit comments