[3.11] gh-101961 fileinput.hookcompressed should not set the encoding value for the binary mode (gh-102068) (#102098)

gh-101961 fileinput.hookcompressed should not set the encoding value for the binary mode (gh-102068)
(cherry picked from commit 6f25657b83)

Co-authored-by: Gihwan Kim <gihwan.kim@linecorp.com>
This commit is contained in:
Miss Islington (bot) 2023-02-20 19:39:16 -08:00 committed by GitHub
parent e9103e69cd
commit 5bc6927c68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 12 deletions

View file

@ -399,7 +399,7 @@ class FileInput:
def hook_compressed(filename, mode, *, encoding=None, errors=None):
if encoding is None: # EncodingWarning is emitted in FileInput() already.
if encoding is None and "b" not in mode: # EncodingWarning is emitted in FileInput() already.
encoding = "locale"
ext = os.path.splitext(filename)[1]
if ext == '.gz':