From 47370526563f591635ce1825020cecbeae4aee07 Mon Sep 17 00:00:00 2001 From: scmtestadf Date: Wed, 25 May 2022 16:20:42 +0200 Subject: [PATCH] Automatic Sync from SCM-svn to GitHub syncing the following commits: RobertRueger: fix issue with closing files for PLAMS trajectories SO-- --- trajectories/trajectoryfile.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/trajectories/trajectoryfile.py b/trajectories/trajectoryfile.py index f10f409c..d9dec54a 100644 --- a/trajectories/trajectoryfile.py +++ b/trajectories/trajectoryfile.py @@ -94,15 +94,6 @@ def __exit__ (self, exc_type, exc_val, exc_tb) : """ self.close() - def __del__ (self) : - """ - If self.file_object is a regular fileobject, close it - """ - try : - self.file.close() - except AttributeError : - pass - def get_elements (self) : """ Get the elements attribute @@ -145,9 +136,10 @@ def get_plamsmol (self) : def close (self) : """ - Cleanly close and garbage collect the file + Close the file """ - del(self) + if hasattr(self.file_object, 'close'): + self.file_object.close() def read_next (self, molecule=None, read=True) : """