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
fileinput.FileInput.readline() always returns str object at the end even if in 'rb' mode #69696
Comments
In Python3, fileinput.FileInput.readline() always returns str object at the end, import fileinput
fi = fileinput.input('test_fileinput.py', mode='rb')
while True:
line = fi.readline()
assert isinstance(line, bytes)
if not len(line):
break It fails in Python3.2 to 3.5. I wrote a patch for this. |
Would be nice to add a test in Lib/test/test_fileinput.py. |
We need to think carefully about backward compatibility here. |
Add a test for fileinput.FileInput.readline() in 'rb' mode. I'm sure this test fails on Python 3.5 and fixed in the patch(fileinput.py.diff). |
LGTM. I don't think we should care about breaking backward compatibility here. Most code tests end-of-files with "not line" or "len(line) == 0", and this work with fixed fileinput as well as with broken. That is why we have received this bug report now, after many years since releasing 3.0. |
New changeset e27c589e1c6a by Serhiy Storchaka in branch '3.4': New changeset 321b34824020 by Serhiy Storchaka in branch '3.5': New changeset 4f0e293e6eb0 by Serhiy Storchaka in branch 'default': |
Thank you Ryosuke for your contribution. |
Ah, I misunderstood the bug report. Yes, this should be OK (I hope :). |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: