diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-01-22 18:10:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-22 18:10:44 (GMT) |
commit | f5d9980217b2f36d095aa58a9b949b828f113082 (patch) | |
tree | bc06152fb4da640f053b523bc546a5d52c617f68 /Lib/ctypes/util.py | |
parent | acea9d8e879c15255a3b08f11729bb1ec6b9fbd6 (diff) | |
download | cpython-f5d9980217b2f36d095aa58a9b949b828f113082.zip cpython-f5d9980217b2f36d095aa58a9b949b828f113082.tar.gz cpython-f5d9980217b2f36d095aa58a9b949b828f113082.tar.bz2 |
[3.11] gh-114257: Ignore the FileNotFound error in ctypes.util._is_elf() (GH-114394) (GH-114445)
(cherry picked from commit 7fc51c3f6b7b13f88480557ff14bdb1c049f9a37)
Co-authored-by: AN Long <aisk@users.noreply.github.com>
Diffstat (limited to 'Lib/ctypes/util.py')
-rw-r--r-- | Lib/ctypes/util.py | 7 |
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 |