Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions magic/loader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ctypes.util import find_library
import ctypes
import logging
import sys
import glob
import os.path
Expand Down Expand Up @@ -40,10 +41,12 @@ def load_lib():
# find_library returns None when lib not found
if lib is None:
continue
try:
return ctypes.CDLL(lib)
except OSError:
pass
if os.path.exists(lib):
try:
return ctypes.CDLL(lib)
except OSError as err:
logging.warning(err)
pass

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this line now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Suggested change
pass

Copy link
Contributor

@cclauss cclauss May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Suggested change
pass

else:
# It is better to raise an ImportError since we are importing magic module
raise ImportError('failed to find libmagic. Check your installation')
Expand Down