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
I'm in the process of migrating from python2 using python-libarchive to python3 using python-libarchive-c. In all, the process has been quite easy (and many thanks to you folks for keeping a similar interface). However, I have run in to a bit of a snag.
I've been detecting whether or not a file is a legitimate archive based on trying to open it and detect errors. This works well for most files, but has been failing when I feed it something that looks like a /etc/passwd file. Previously, when libarchive returns Missing type keyword in mtree specification, the old python-libarchive would raise a ValueError. Now, this simply produces a Warning to the logger and the process continues.
Is there an easy way to make this produce an error that I can catch or otherwise detect invalid archives?
The text was updated successfully, but these errors were encountered:
You should be able to intercept the warning message and turn it into an exception by modifying the libarchive.ffi.logger object. The simplest way to do that is probably to replace the logger's warning method. A cleaner solution could be to create a special Handler and call logger.addHandler(handler).
I'm in the process of migrating from python2 using python-libarchive to python3 using python-libarchive-c. In all, the process has been quite easy (and many thanks to you folks for keeping a similar interface). However, I have run in to a bit of a snag.
I've been detecting whether or not a file is a legitimate archive based on trying to open it and detect errors. This works well for most files, but has been failing when I feed it something that looks like a
/etc/passwd
file. Previously, when libarchive returnsMissing type keyword in mtree specification
, the old python-libarchive would raise a ValueError. Now, this simply produces a Warning to the logger and the process continues.Is there an easy way to make this produce an error that I can catch or otherwise detect invalid archives?
The text was updated successfully, but these errors were encountered: