-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unclosed file warning in GiftiImage.to_file_map
#1035
Labels
Comments
Yup, good catch. I think we assumed the garbage collector would clean up for us... Fortunately this is a context manager: Lines 185 to 189 in 62aea04
So we should be able to write: with file_map['image'].get_prepare_fileobj('wb') as f:
f.write(self.to_xml()) Would you mind making the PR? And is there a minimal reproduction where we can always emit the warning? If so, it'd be good to have a test. |
HippocampusGirl
added a commit
to HippocampusGirl/nibabel
that referenced
this issue
Aug 5, 2021
- Change as proposed by @effigies
HippocampusGirl
added a commit
to HippocampusGirl/nibabel
that referenced
this issue
Aug 5, 2021
- Change as proposed by @effigies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get the following warning when
fMRIPrep
tries to write a GIfTI fileThe code on the
fMRIPrep
side looks fine (see https://github.com/nipreps/niworkflows/blob/691436a28c10aa8f1d39cbad37610220e49f3abd/niworkflows/interfaces/surf.py#L303).As far as I can tell, this could be resolved by adding a call to
close_if_mine
at the end of the function.nibabel/nibabel/gifti/gifti.py
Lines 865 to 881 in 88e4761
The text was updated successfully, but these errors were encountered: