Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop #70659

Closed
DarkMagus mannequin opened this issue Mar 2, 2016 · 2 comments
Closed

Infinite loop #70659

DarkMagus mannequin opened this issue Mar 2, 2016 · 2 comments
Labels
topic-IO type-bug An unexpected behavior, bug, or error

Comments

@DarkMagus
Copy link
Mannequin

DarkMagus mannequin commented Mar 2, 2016

BPO 26472
Nosy @tiran

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2016-03-02.13:29:14.592>
created_at = <Date 2016-03-02.13:22:54.792>
labels = ['type-bug', 'invalid', 'expert-IO']
title = 'Infinite loop'
updated_at = <Date 2016-03-02.13:29:14.590>
user = 'https://bugs.python.org/DarkMagus'

bugs.python.org fields:

activity = <Date 2016-03-02.13:29:14.590>
actor = 'christian.heimes'
assignee = 'none'
closed = True
closed_date = <Date 2016-03-02.13:29:14.592>
closer = 'christian.heimes'
components = ['IO']
creation = <Date 2016-03-02.13:22:54.792>
creator = 'DarkMagus'
dependencies = []
files = []
hgrepos = []
issue_num = 26472
keywords = []
message_count = 2.0
messages = ['261113', '261114']
nosy_count = 2.0
nosy_names = ['christian.heimes', 'DarkMagus']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue26472'
versions = ['Python 3.5']

@DarkMagus
Copy link
Mannequin Author

DarkMagus mannequin commented Mar 2, 2016

The code below runs indefinitely:

with open(False) as f:
    for line in f:
        print(line)

@DarkMagus DarkMagus mannequin added topic-IO type-bug An unexpected behavior, bug, or error labels Mar 2, 2016
@tiran
Copy link
Member

tiran commented Mar 2, 2016

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)

@tiran tiran closed this as completed Mar 2, 2016
@tiran tiran added the invalid label Mar 2, 2016
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-IO type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant