plugins/python/example_io_plugin.py: fix backtrace during destructor

If the plugin fails to open the file for writing, constructor will raise
an exception and exit before creating the "_log" member variable.
So the destructor will also raise a backtrace. (Which python ignores, but
dumps out to stderr.)
This commit is contained in:
Robert Manner
2020-01-07 17:30:42 +01:00
committed by Todd C. Miller
parent 5be81eb25b
commit 591d57ad28

View File

@@ -61,6 +61,7 @@ class SudoIOPlugin(sudo.Plugin):
self._log("", "-- Plugin STARTED --")
def __del__(self):
if hasattr(self, "_log_file"):
self._log("", "-- Plugin DESTROYED --")
def open(self, argv: Tuple[str, ...], command_info: Tuple[str, ...]) -> int: