Skip to content

Commit 4194182

Browse files
authored
πŸ› fix: catch ImportError for missing sqlite3 C library (#475)
The previous fix caught ModuleNotFoundError, which only covers the case where the Python sqlite3 module is entirely absent. In minimal Docker images the Python package exists but the underlying libsqlite3.so.0 is missing, raising ImportError instead. Since ModuleNotFoundError is a subclass of ImportError, catching the parent handles both scenarios.
1 parent 9b2d086 commit 4194182

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

β€Žsrc/filelock/__init__.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
try:
1919
from ._read_write import ReadWriteLock
20-
except ModuleNotFoundError: # sqlite3 may be unavailable if Python was built without it
20+
except ImportError: # sqlite3 may be unavailable if Python was built without it or the C library is missing
2121
ReadWriteLock = None # type: ignore[assignment, misc]
2222

2323
from ._soft import SoftFileLock

β€Žtests/conftest.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
try:
44
from filelock._read_write import _cleanup_connections
5-
except ModuleNotFoundError:
5+
except ImportError:
66
_cleanup_connections = None # type: ignore[assignment, misc]
77

88

0 commit comments

Comments
Β (0)