File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -96,8 +96,11 @@ def find_library(name):
9696 def _is_elf (filename ):
9797 "Return True if the given file is an ELF file"
9898 elf_header = b'\x7f ELF'
99- with open (filename , 'br' ) as thefile :
100- return thefile .read (4 ) == elf_header
99+ try :
100+ with open (filename , 'br' ) as thefile :
101+ return thefile .read (4 ) == elf_header
102+ except FileNotFoundError :
103+ return False
101104
102105 def _findLib_gcc (name ):
103106 # Run GCC's linker with the -t (aka --trace) option and examine the
Original file line number Diff line number Diff line change @@ -122,6 +122,9 @@ def test_find_library_with_ld(self):
122122 unittest .mock .patch ("ctypes.util._findLib_gcc" , lambda * args : None ):
123123 self .assertNotEqual (find_library ('c' ), None )
124124
125+ def test_gh114257 (self ):
126+ self .assertIsNone (find_library ("libc" ))
127+
125128
126129if __name__ == "__main__" :
127130 unittest .main ()
Original file line number Diff line number Diff line change 1+ Dismiss the :exc: `FileNotFound ` error in :func: `ctypes.util.find_library ` and
2+ just return ``None `` on Linux.
You can’t perform that action at this time.
0 commit comments