File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -33,21 +33,26 @@ def _guess_lib_name():
33
33
34
34
35
35
def _load_library (name ):
36
+ """Try to load a dynamic library with ctypes, or return None if the
37
+ library is not available.
38
+ """
36
39
if sys .platform == 'win32' :
37
- try :
38
- return ctypes .cdll .LoadLibrary (ctypes .util .find_library (name ))
39
- except TypeError :
40
- raise OSError ()
41
- else :
40
+ # On Windows since Python 3.8, we need an extra call to
41
+ # `find_library` to search standard library paths.
42
+ name = ctypes .util .find_library (name )
43
+ if not name :
44
+ return None
45
+
46
+ try :
42
47
return ctypes .cdll .LoadLibrary (name )
48
+ except OSError :
49
+ return None
43
50
44
51
45
52
for name in _guess_lib_name ():
46
- try :
47
- _libchromaprint = _load_library ( name )
53
+ _libchromaprint = _load_library ( name )
54
+ if _libchromaprint :
48
55
break
49
- except OSError :
50
- pass
51
56
else :
52
57
raise ImportError ("couldn't find libchromaprint" )
53
58
You can’t perform that action at this time.
0 commit comments