summaryrefslogtreecommitdiffstats
path: root/Lib/ctypes
diff options
context:
space:
mode:
authorAN Long <aisk@users.noreply.github.com>2024-01-22 17:15:29 (GMT)
committerGitHub <noreply@github.com>2024-01-22 17:15:29 (GMT)
commit7fc51c3f6b7b13f88480557ff14bdb1c049f9a37 (patch)
tree3964242126169c19450d54fe37531f00d6b4f702 /Lib/ctypes
parented30a3c337f30abd2ea5357565a956ed3dc0719c (diff)
downloadcpython-7fc51c3f6b7b13f88480557ff14bdb1c049f9a37.zip
cpython-7fc51c3f6b7b13f88480557ff14bdb1c049f9a37.tar.gz
cpython-7fc51c3f6b7b13f88480557ff14bdb1c049f9a37.tar.bz2
gh-114257: Ignore the FileNotFound error in ctypes.util._is_elf() (GH-114394)
Diffstat (limited to 'Lib/ctypes')
-rw-r--r--Lib/ctypes/util.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index 0c2510e..c550883 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -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