You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While writing a script to find all dl-opened libraries on a system, I ran into this assert when encountering .py files:
Traceback (most recent call last):
File "/usr/bin/dlopen-notes", line 142, in <module>
notes = [read_dlopen_notes(filename) for filename in args.filenames]
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/bin/dlopen-notes", line 24, in wrap
return list(f(*args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/bin/dlopen-notes", line 29, in read_dlopen_notes
elffile = ELFFile(open(filename, 'rb'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/elftools/elf/elffile.py", line 84, in __init__
self._identify_file()
File "/usr/lib/python3.12/site-packages/elftools/elf/elffile.py", line 570, in _identify_file
elf_assert(magic == b'\x7fELF', 'Magic number does not match')
File "/usr/lib/python3.12/site-packages/elftools/common/utils.py", line 80, in elf_assert
_assert_with_exception(cond, msg, ELFError)
File "/usr/lib/python3.12/site-packages/elftools/common/utils.py", line 143, in _assert_with_exception
raise exception_type(msg)
elftools.common.exceptions.ELFError: Magic number does not match
Ideally, invalid & non-existent files (& directories) wouldn't cause asserts like this.
I think the idea is to just not invoke it on files that it doesn't understand. We could add a wrapper not to print the exception, but having it printed helps with debuging… This is not a "crash", just "graceful verbose error handling" ;)
Activity
keszybz commentedon Jun 2, 2026
I think the idea is to just not invoke it on files that it doesn't understand. We could add a wrapper not to print the exception, but having it printed helps with debuging… This is not a "crash", just "graceful verbose error handling" ;)