From a37e03942430df203f3b60581db81dc0dca6646f Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 14 Jan 2024 18:57:23 +0100 Subject: [PATCH] Check input_file attribut --- RNS/Resource.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/RNS/Resource.py b/RNS/Resource.py index f77c3e5..a739bc1 100644 --- a/RNS/Resource.py +++ b/RNS/Resource.py @@ -625,11 +625,13 @@ class Resource: except Exception as e: RNS.log("Error while executing resource concluded callback from "+str(self)+". The contained exception was: "+str(e), RNS.LOG_ERROR) finally: - if hasattr(self.input_file, "close") and callable(self.input_file.close): - try: - self.input_file.close() - except Exception as e: - RNS.log("Error while closing resource input file: "+str(e), RNS.LOG_ERROR) + try: + if hasattr(self, "input_file"): + if hasattr(self.input_file, "close") and callable(self.input_file.close): + self.input_file.close() + + except Exception as e: + RNS.log("Error while closing resource input file: "+str(e), RNS.LOG_ERROR) else: # Otherwise we'll recursively create the # next segment of the resource