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
gzip.open() needs an optional encoding argument #56768
Comments
gzip.open() should parallel file.open() so that that zipped files can be read in the same way as regular files: for line in gzip.open('notes.txt', 'r', encoding='latin-1'):
print(line.rstrip()) |
Here is a patch. If the code changes are acceptable I can also make a documentation patch. (I'm surprised to see 3.2 in "Versions". I thought 3.2 only gets bugfixes...) |
There remains a difference between open() and gzip.open(): Don't know how to fix this though. |
If we go this way, the "errors" and "newline" argument should be added as well. |
Yeah, I thought about that. I can make a new patch, that implement this, if needed. Though it seems there is a real problem, the one that Amaury Forgeot d'Arc mentioned. I can't think of a way to solve it in a backwards compatible way. |
Why not use io.TextWrapper? I think it is the right answer for this issue. |
I already fixed this without knowing about this issue; see 55202ca694d7. storchaka:
The proposed patch (and the code I committed) *do* use TextIOWrapper. Unless you mean that callers should create the TextIOWrapper themselves. amaury.forgeotdarc:
The committed code unfortunately still has gzip.open(filename, "r") However, it does provide a way to open a text file with the system's |
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: