unittest.mock.patch("ctypes.util._findLib_gcc", lambda *args: None):
self.assertNotEqual(find_library('c'), None)
+ def test_gh114257(self):
+ self.assertIsNone(find_library("libc"))
+
if __name__ == "__main__":
unittest.main()
def _is_elf(filename):
"Return True if the given file is an ELF file"
elf_header = b'\x7fELF'
- with open(filename, 'br') as thefile:
- return thefile.read(4) == elf_header
+ try:
+ with open(filename, 'br') as thefile:
+ return thefile.read(4) == elf_header
+ except FileNotFoundError:
+ return False
def _findLib_gcc(name):
# Run GCC's linker with the -t (aka --trace) option and examine the
--- /dev/null
+Dismiss the :exc:`FileNotFound` error in :func:`ctypes.util.find_library` and
+just return ``None`` on Linux.