This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Infinite loop
Type: behavior Stage: resolved
Components: IO Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: DarkMagus, christian.heimes
Priority: normal Keywords:

Created on 2016-03-02 13:22 by DarkMagus, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg261113 - (view) Author: Tibichte (DarkMagus) Date: 2016-03-02 13:22
The code below runs indefinitely:

with open(False) as f:
    for line in f:
        print(line)
msg261114 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2016-03-02 13:29
In open(False) Fale is interpreted as int 0. The function call opens file descriptor 0 (stdin) and waits for incoming data.

Try this code, enter some text and press enter to see what is going on:

with open(False) as f:
    for line in f:
        print('stdin: ', line)
History
Date User Action Args
2022-04-11 14:58:28adminsetgithub: 70659
2016-03-02 13:29:14christian.heimessetstatus: open -> closed

nosy: + christian.heimes
messages: + msg261114

resolution: not a bug
stage: resolved
2016-03-02 13:22:54DarkMaguscreate