Skip to content

Commit 08ccd0b

Browse files
Fix #1035 unclosed file warning in GiftiImage
- Change as proposed by @effigies
1 parent ea68c4e commit 08ccd0b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

nibabel/gifti/gifti.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,8 @@ def to_file_map(self, file_map=None):
877877
"""
878878
if file_map is None:
879879
file_map = self.file_map
880-
f = file_map['image'].get_prepare_fileobj('wb')
881-
f.write(self.to_xml())
880+
with file_map['image'].get_prepare_fileobj('wb') as f:
881+
f.write(self.to_xml())
882882

883883
@classmethod
884884
def from_file_map(klass, file_map, buffer_size=35000000, mmap=True):

0 commit comments

Comments
 (0)