File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,20 @@ def glibc_version_string_ctypes() -> Optional[str]:
40
40
# manpage says, "If filename is NULL, then the returned handle is for the
41
41
# main program". This way we can let the linker do the work to figure out
42
42
# which libc our process is actually using.
43
- process_namespace = ctypes .CDLL (None )
43
+ #
44
+ # We must also handle the special case where the executable is not a
45
+ # dynamically linked executable. This can occur when using musl libc,
46
+ # for example. In this situation, dlopen() will error, leading to an
47
+ # OSError. Interestingly, at least in the case of musl, there is no
48
+ # errno set on the OSError. The single string argument used to construct
49
+ # OSError comes from libc itself and is therefore not portable to
50
+ # hard code here. In any case, failure to call dlopen() means we
51
+ # can proceed, so we bail on our attempt.
52
+ try :
53
+ process_namespace = ctypes .CDLL (None )
54
+ except OSError :
55
+ return None
56
+
44
57
try :
45
58
gnu_get_libc_version = process_namespace .gnu_get_libc_version
46
59
except AttributeError :
You can’t perform that action at this time.
0 commit comments