diff --git a/can/bus.py b/can/bus.py index 3964215d3..5bd2d4e30 100644 --- a/can/bus.py +++ b/can/bus.py @@ -439,7 +439,7 @@ def __exit__(self, exc_type, exc_val, exc_tb): def __del__(self) -> None: if not self._is_shutdown: - LOG.warning("%s was not properly shut down", self.__class__) + LOG.warning("%s was not properly shut down", self.__class__.__name__) # We do some best-effort cleanup if the user # forgot to properly close the bus instance with contextlib.suppress(AttributeError): diff --git a/can/interfaces/vector/canlib.py b/can/interfaces/vector/canlib.py index e60d20b0d..03a3d9b1f 100644 --- a/can/interfaces/vector/canlib.py +++ b/can/interfaces/vector/canlib.py @@ -6,6 +6,7 @@ # Import Standard Python Modules # ============================== +import contextlib import ctypes import logging import os @@ -869,9 +870,11 @@ def flush_tx_buffer(self) -> None: def shutdown(self) -> None: super().shutdown() - self.xldriver.xlDeactivateChannel(self.port_handle, self.mask) - self.xldriver.xlClosePort(self.port_handle) - self.xldriver.xlCloseDriver() + + with contextlib.suppress(VectorError): + self.xldriver.xlDeactivateChannel(self.port_handle, self.mask) + self.xldriver.xlClosePort(self.port_handle) + self.xldriver.xlCloseDriver() def reset(self) -> None: self.xldriver.xlDeactivateChannel(self.port_handle, self.mask)