Skip to content

Commit 1415238

Browse files
UnitedMarsupialsMikhail T
andauthored
[inotify] Simplify libc loading (#776)
libc is used by the Python interpreter itself, thus dlopen(NULL) is sufficient, no need to load the library again. Co-authored-by: Mikhail T <[email protected]>
1 parent 7728a45 commit 1415238

File tree

1 file changed

+1
-33
lines changed

1 file changed

+1
-33
lines changed

src/watchdog/observers/inotify_c.py

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,7 @@
2525
from ctypes import c_int, c_char_p, c_uint32
2626
from watchdog.utils import UnsupportedLibc
2727

28-
29-
def _load_libc():
30-
libc_path = None
31-
try:
32-
libc_path = ctypes.util.find_library('c')
33-
except (OSError, RuntimeError):
34-
# Note: find_library will on some platforms raise these undocumented
35-
# errors, e.g.on android OSError "No usable temporary directory found"
36-
# will be raised.
37-
pass
38-
39-
if libc_path is not None:
40-
return ctypes.CDLL(libc_path)
41-
42-
# Fallbacks
43-
try:
44-
return ctypes.CDLL('libc.so')
45-
except OSError:
46-
pass
47-
48-
try:
49-
return ctypes.CDLL('libc.so.6')
50-
except OSError:
51-
pass
52-
53-
# uClibc
54-
try:
55-
return ctypes.CDLL('libc.so.0')
56-
except OSError as err:
57-
raise err
58-
59-
60-
libc = _load_libc()
28+
libc = ctypes.CDLL(None)
6129

6230
if not hasattr(libc, 'inotify_init') or \
6331
not hasattr(libc, 'inotify_add_watch') or \

0 commit comments

Comments
 (0)