From ea4f821b778dd7adafc2b88e01fef0f4b1c008e4 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Wed, 17 Feb 2021 20:23:08 +0000 Subject: [PATCH] MNT: Prevent errors at GC (Image), and when files are removed before atexit (settings) --- fsl/data/image.py | 3 ++- fsl/utils/settings.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fsl/data/image.py b/fsl/data/image.py index 7c2bdbcba..0dbd331af 100644 --- a/fsl/data/image.py +++ b/fsl/data/image.py @@ -1206,7 +1206,8 @@ class Image(Nifti): def __del__(self): """Closes any open file handles, and clears some references. """ - Nifti.__del__(self) + if Nifti is not None: + Nifti.__del__(self) self.__nibImage = None self.__imageWrapper = None diff --git a/fsl/utils/settings.py b/fsl/utils/settings.py index ceeb6bfe9..523caddc1 100644 --- a/fsl/utils/settings.py +++ b/fsl/utils/settings.py @@ -421,7 +421,7 @@ class Settings(object): try: with open(configFile, 'wb') as f: pickle.dump(config, f, protocol=2) - except (IOError, pickle.PicklingError, EOFError): + except (IOError, pickle.PicklingError, EOFError, FileNotFoundError): log.warning('Unable to save {} configuration file ' '{}'.format(self.__configID, configFile), exc_info=True) -- GitLab