Eryk Sun <eryk...@gmail.com> added the comment:

Issue 41976 added ctypes.util._is_elf() to filter out linker scripts such as 
"libc.so". The PR was backported to 3.7. _is_elf() assumes the trace result has 
absolute paths that can be opened, but Matthias is getting the relative 
filename "liblibc.a" in the result. Whatever the reason, I think if the file 
can't be opened for reading, then _is_elf() should just return False. For 
example:

    def _is_elf(filename):
        "Return True if the given file is an ELF file"
        elf_header = b'\x7fELF'
        try:
            with open(filename, 'br') as thefile:
                return thefile.read(4) == elf_header
        except OSError:
            return False

----------
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42580>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to