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.
This commit is contained in:
parent
ebc793d6ac
commit
11fa0e48a9
|
@ -816,7 +816,7 @@ are always available. They are listed here in alphabetical order.
|
|||
|
||||
from functools import partial
|
||||
with open('mydata.db', 'rb') as f:
|
||||
for block in iter(partial(f.read, 64), ''):
|
||||
for block in iter(partial(f.read, 64), b''):
|
||||
process_block(block)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue