Skip to content

Commit a085e24

Browse files
committed
Use builtins.open rather than io.open
1 parent 3a1cd20 commit a085e24

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/isal/igzip.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
Library to speed up its methods."""
3030

3131
import argparse
32+
import builtins
3233
import gzip
3334
import io
3435
import os
@@ -342,9 +343,9 @@ def main():
342343
if args.file is None:
343344
in_file = sys.stdin.buffer
344345
else:
345-
in_file = io.open(args.file, mode="rb")
346+
in_file = builtins.open(args.file, mode="rb")
346347
if out_filepath is not None:
347-
out_buffer = io.open(out_filepath, "wb")
348+
out_buffer = builtins.open(out_filepath, "wb")
348349
else:
349350
out_buffer = sys.stdout.buffer
350351

@@ -360,7 +361,7 @@ def main():
360361
else:
361362
in_file = IGzipFile(mode="rb", fileobj=sys.stdin.buffer)
362363
if out_filepath is not None:
363-
out_file = io.open(out_filepath, mode="wb")
364+
out_file = builtins.open(out_filepath, mode="wb")
364365
else:
365366
out_file = sys.stdout.buffer
366367

src/isal/igzip_threaded.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# This file is part of python-isal which is distributed under the
66
# PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2.
77

8+
import builtins
89
import io
910
import multiprocessing
1011
import os
@@ -54,7 +55,7 @@ def open(filename, mode="rb", compresslevel=igzip._COMPRESS_LEVEL_TRADEOFF,
5455
threads = 1
5556
open_mode = mode.replace("t", "b")
5657
if isinstance(filename, (str, bytes)) or hasattr(filename, "__fspath__"):
57-
binary_file = io.open(filename, open_mode)
58+
binary_file = builtins.open(filename, open_mode)
5859
elif hasattr(filename, "read") or hasattr(filename, "write"):
5960
binary_file = filename
6061
else:
@@ -261,6 +262,8 @@ def flush(self):
261262
self.raw.flush()
262263

263264
def close(self) -> None:
265+
if self._closed:
266+
return
264267
self.flush()
265268
self.stop()
266269
if self.exception:

0 commit comments

Comments
 (0)