gh-114257: Ignore the FileNotFound error in ctypes.util._is_elf() (GH-114394)

This commit is contained in:
AN Long 2024-01-23 01:15:29 +08:00 committed by GitHub
parent ed30a3c337
commit 7fc51c3f6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 2 deletions

View file

@ -96,8 +96,11 @@ elif os.name == "posix":
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