Berker Peksag <berker.pek...@gmail.com> added the comment:

Thank you for the report and the PR!

I think accepting 'rt' mode is a good idea. However, it's a new feature and it 
can only go into 3.8.

It seems to me that the root cause of the issue is that the fileinput module 
wasn't properly converted to support Python 3. Perhaps we could change 'r' to 
'rt' in FileInput.__init__() or hook_compressed() to make it work properly, so 
the example in issue 5758 would work as expected without changing any user code:

# test.py

import fileinput

for line in fileinput.FileInput(openhook=fileinput.hook_compressed):
    print(line.rstrip())


$ ./python.exe test.py mike.txt mike.txt.gz
Hello from Mike.
This is the second line.
Why did the robot cross the road?
Hello from Mike.
This is the second line.
Why did the robot cross the road?

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36865>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to