Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9d625c2

Browse files
committed
Buglet: restore functioning of gzip as an executable when (de)compressing from stdin to stdout
1 parent d6d63f5 commit 9d625c2

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Lib/gzip.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,8 @@ def _test():
473473
for arg in args:
474474
if decompress:
475475
if arg == "-":
476-
f = GzipFile(filename="", mode="rb", fileobj=sys.stdin)
477-
g = sys.stdout
476+
f = GzipFile(filename="", mode="rb", fileobj=sys.stdin.buffer)
477+
g = sys.stdout.buffer
478478
else:
479479
if arg[-3:] != ".gz":
480480
print("filename doesn't end in .gz:", repr(arg))
@@ -483,8 +483,8 @@ def _test():
483483
g = builtins.open(arg[:-3], "wb")
484484
else:
485485
if arg == "-":
486-
f = sys.stdin
487-
g = GzipFile(filename="", mode="wb", fileobj=sys.stdout)
486+
f = sys.stdin.buffer
487+
g = GzipFile(filename="", mode="wb", fileobj=sys.stdout.buffer)
488488
else:
489489
f = builtins.open(arg, "rb")
490490
g = open(arg + ".gz", "wb")

0 commit comments

Comments
 (0)