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 @@ -125,6 +125,9 @@ def test_find_library_with_ld(self):
125125 unittest .mock .patch ("ctypes.util._findLib_gcc" , lambda * args : None ):
126126 self .assertNotEqual (find_library ('c' ), None )
127127
128+ def test_gh114257 (self ):
129+ self .assertIsNone (find_library ("libc" ))
130+
128131
129132if __name__ == "__main__" :
130133 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