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.

Author eric.smith
Recipients eric.smith, vinayakuh
Date 2021-09-30.06:56:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1632985019.08.0.875445131109.issue45327@roundup.psfhosted.org>
In-reply-to
Content
The issue is that False is causing a read from stdin, since False == 0.

>>> open(0).readlines()
test
['test\n']

Here I typed "test", followed by Ctrl-D (end of file). readlines() then completed and printed its result.

I think the basic answer here is "don't do this". It's not a bug, and is documented.

https://docs.python.org/3/library/functions.html#open
says:
file is a path-like object giving the pathname (absolute or relative to the current working directory) of the file to be opened or an integer file descriptor of the file to be wrapped.

So an integer file descriptor False is causing stdin to be wrapped.

>>> False == 0
True
>>> isinstance(False, int)
True
History
Date User Action Args
2021-09-30 06:56:59eric.smithsetrecipients: + eric.smith, vinayakuh
2021-09-30 06:56:59eric.smithsetmessageid: <1632985019.08.0.875445131109.issue45327@roundup.psfhosted.org>
2021-09-30 06:56:59eric.smithlinkissue45327 messages
2021-09-30 06:56:58eric.smithcreate