Why does tarfile.extractall ignore default errors?

The Python tarfile module ignores errors during extraction by default if it is errorlevelnot set to 1or 2(or from debugto 1, if you want to print only error messages).

Try mkdir /tmp/foo && sudo chown root /tmp/foo && chmod a-w /tmp/fooand use tarfile.tar.gz to extract the file to /tmp/foo- you will see that your Python code did not rule out at all. Files would not be extracted on top /tmp/foo, which is still an empty directory.

Why is this behavior? Who / what benefits from this default behavior ? In other words, who or what would like to ignore, say, tarfile decompression errors?

+3
source share
1 answer

FWIW, this nasty behavior will be changed in Python 2.7 and 3.2. http://svn.python.org/view?view=rev&revision=76780 Apparently, the reason for ignoring errors used to be more like GNU tar, which ignores errors.

+2
source

Source: https://habr.com/ru/post/1727565/


All Articles