Skip to content

Commit 4edc533

Browse files
committed
Use shutil.copyfileobj for fileobj copying
1 parent 61c4f6e commit 4edc533

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/zlib_ng/gzip_ng.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import gzip
2323
import io
2424
import os
25+
import shutil
2526
import struct
2627
import sys
2728
import time
@@ -302,11 +303,7 @@ def main():
302303
global READ_BUFFER_SIZE
303304
READ_BUFFER_SIZE = args.buffer_size
304305
try:
305-
while True:
306-
block = in_file.read(args.buffer_size)
307-
if block == b"":
308-
break
309-
out_file.write(block)
306+
shutil.copyfileobj(in_file, out_file, args.buffer_size)
310307
finally:
311308
if in_file is not sys.stdin.buffer:
312309
in_file.close()

0 commit comments

Comments
 (0)