[Python-checkins] Doc: fix example for iter() function. (GH-11959)
Serhiy Storchaka
webhook-mailer at python.org
Thu Feb 21 02:53:10 EST 2019
https://github.com/python/cpython/commit/11fa0e48a958716186eb99348a46064e944eccf6
commit: 11fa0e48a958716186eb99348a46064e944eccf6
branch: master
author: Cristian Ciupitu <cristian.ciupitu at yahoo.com>
committer: Serhiy Storchaka <storchaka at gmail.com>
date: 2019-02-21T09:53:06+02:00
summary:
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.
files:
M Doc/library/functions.rst
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index cca28ff5fb3b..ebbee71f48ed 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -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)
More information about the Python-checkins
mailing list