Skip to content

Commit 46fa40f

Browse files
vincentbernatgpotter2
authored andcommitted
Fix ctypes usage with Python 3.9
There is a regression in Python 3.9 with the `find_library()` function: >>> import ctypes.util >>> ctypes.util.find_library("libc") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.9/ctypes/util.py", line 341, in find_library _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name)) File "/usr/lib/python3.9/ctypes/util.py", line 147, in _findLib_gcc if not _is_elf(file): File "/usr/lib/python3.9/ctypes/util.py", line 99, in _is_elf with open(filename, 'br') as thefile: FileNotFoundError: [Errno 2] No such file or directory: b'liblibc.a' A workaround is to use `find_library("c")` instead. It also works in older versions of Python and that's already what's used in `contrib/isotp.py`. Python issue reported here: https://bugs.python.org/issue42580 Signed-off-by: Vincent Bernat <[email protected]>
1 parent 81603d1 commit 46fa40f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scapy/arch/bpf/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
# ctypes definitions
3434

35-
LIBC = cdll.LoadLibrary(find_library("libc"))
35+
LIBC = cdll.LoadLibrary(find_library("c"))
3636

3737
LIBC.ioctl.argtypes = [c_int, c_ulong, c_char_p]
3838
LIBC.ioctl.restype = c_int

0 commit comments

Comments
 (0)