From 92ac01b104b80f9251fcb17ab4cc1845c1f91ac2 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Wed, 20 Feb 2019 23:59:28 -0800 Subject: 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. (cherry picked from commit 11fa0e48a958716186eb99348a46064e944eccf6) Co-authored-by: Cristian Ciupitu --- Doc/library/functions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Doc/library') diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index abf3e26d9e..b28f28f214 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -815,7 +815,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) -- cgit v1.2.1