We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 339eac0 commit a9e6276Copy full SHA for a9e6276
1 file changed
magic/loader.py
@@ -3,7 +3,9 @@
3
import sys
4
import glob
5
import os.path
6
+import logging
7
8
+logger = logging.getLogger(__name__)
9
10
def _lib_candidates_linux():
11
"""Yield possible libmagic library names on Linux.
@@ -61,11 +63,15 @@ def _lib_candidates():
61
63
def load_lib():
62
64
for lib in _lib_candidates():
65
# find_library returns None when lib not found
- if lib:
- try:
66
- return ctypes.CDLL(lib)
67
- except OSError:
68
- pass
+ if lib is None:
+ continue
+ if not os.path.exists(lib):
69
70
+
71
+ try:
72
+ return ctypes.CDLL(lib)
73
+ except OSError:
74
+ logger.warning("Failed to load: " + lib, exc_info=True)
75
76
# It is better to raise an ImportError since we are importing magic module
77
raise ImportError("python-magic: failed to find libmagic. Check your installation")
0 commit comments