Skip to content

Commit e96d71c

Browse files
committed
RF: keep_file_open == 'auto' now causes file handles to be kept open if
indexed_gzip is used, or dropped if gzip is used. Default value for keep_file_open is now False. Warn that 'auto' will be deprecated soon.
1 parent d5ad97a commit e96d71c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

nibabel/arrayproxy.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@
5151
If this is set to any other value, attempts to create an ``ArrayProxy`` without
5252
specifying the ``keep_file_open`` flag will result in a ``ValueError`` being
5353
raised.
54+
55+
.. warning:: Setting this flag to a value of ``'auto'`` will become deprecated
56+
behaviour in version 2.4.0. Support for ``'auto'`` will be removed
57+
in version 3.0.0.
5458
"""
55-
KEEP_FILE_OPEN_DEFAULT = 'auto'
59+
KEEP_FILE_OPEN_DEFAULT = False
5660

5761

5862
class ArrayProxy(object):

nibabel/openers.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ def _gzip_open(filename, mode='rb', compresslevel=9, keep_open=False):
9090
# True, we tell IndexedGzipFile to keep the file handle open. Otherwise
9191
# the IndexedGzipFile will close/open the file on each read.
9292
if HAVE_INDEXED_GZIP and mode == 'rb':
93-
gzip_file = IndexedGzipFile(
94-
filename, drop_handles=keep_open is not True)
93+
gzip_file = IndexedGzipFile(filename, drop_handles=not keep_open)
9594

9695
# Fall-back to built-in GzipFile (wrapped with the BufferedGzipFile class
9796
# defined above)

0 commit comments

Comments
 (0)