Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 11fa0e4

Browse files
ciupicriserhiy-storchaka
authored andcommitted
Doc: fix example for iter() function. (GH-11959)
read() returns bytes for a file opened in binary mode, so b'' should be used as a sentinel instead of ''. Otherwise the loop will be infinite.
1 parent ebc793d commit 11fa0e4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Doc/library/functions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ are always available. They are listed here in alphabetical order.
816816

817817
from functools import partial
818818
with open('mydata.db', 'rb') as f:
819-
for block in iter(partial(f.read, 64), ''):
819+
for block in iter(partial(f.read, 64), b''):
820820
process_block(block)
821821

822822

0 commit comments

Comments
 (0)