Skip to content

Commit

Permalink
Fix a problem when the library load failed
Browse files Browse the repository at this point in the history
The error was:
Exception ignored in: <function PyKCS11Lib.__del__ at 0x10dfa1bc0>
Traceback (most recent call last):
  File ".../PyKCS11/PyKCS11/__init__.py", line 478, in __del__
KeyError: '/path/to/invalid/lib.so'
  • Loading branch information
LudovicRousseau committed Apr 16, 2024
1 parent 1287b8a commit 20429de
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions PyKCS11/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,10 @@ def __del__(self):
if not hasattr(self, "pkcs11dll_filename"):
return

# in case the load failed
if self.pkcs11dll_filename not in PyKCS11Lib._loaded_libs:
return

# decrease user number
PyKCS11Lib._loaded_libs[self.pkcs11dll_filename]["nb_users"] -= 1

Expand Down

0 comments on commit 20429de

Please sign in to comment.