Closed jtlz2 closed 3 years ago
The simple but not very useful answer is that python-magic is a thin wrapper around libmagic, so does whatever libmagic does :)
When from_buffer(..., mime=True) cannot identify the format it returns 'application/octet-stream'.
magic.from_buffer() could throw because:
a) libmagic is not found, this will produce an ImportError b) magic_load cannot find any magic database files, this will produce a MagicException
magic.from_buffer will never return None because a null return from from_buffer is turned into an exception.
In theory magic_buffer could fail but the docs are not descriptive about when/if this could happen; I've not see it except for a bug in libmagic 5.09.
Hope this helps!
I am using this excellent module as follows:
If
bytes_data
is unrecognisable, or mangled, what is returned by.from_buffer()
?What possible
exceptions
are thrown, orNone
s returned?What is the default?
Thank you so much