From c712dcf238c38ea069fac2c9281317fca229472f Mon Sep 17 00:00:00 2001 From: mxmlnkn Date: Wed, 18 Sep 2024 21:15:32 +0200 Subject: [PATCH] [fix] Suppress teardown warning in case the mount source was not even created yet --- ratarmount.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ratarmount.py b/ratarmount.py index 4eedb3bc..003db5fb 100755 --- a/ratarmount.py +++ b/ratarmount.py @@ -681,7 +681,9 @@ def __del__(self) -> None: print("[Warning] Failed to close mount point folder descriptor because of:", exception) try: - self.mountSource.__exit__(None, None, None) + # If there is some exception in the constructor, then some members may not exist! + if hasattr(self, 'mountSource'): + self.mountSource.__exit__(None, None, None) except Exception as exception: if self.printDebug >= 1: print("[Warning] Failed to tear down root mount source because of:", exception)