Title: tarfile: ignore_zeros = True won't raise exception even on invalid (non-zero) TARs
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: mxmlnkn
Priority: normal Keywords:

Created on 2020-05-24 18:10 by mxmlnkn, last changed 2020-05-24 18:10 by mxmlnkn.

Messages (1)
msg369816 - (view) Author: mxmlnkn (mxmlnkn) Date: 2020-05-24 18:10
Normally, when opening an existing non-TAR file, e.g., a file with random data, an exception is raised: "foo.txt" )

    ReadError                                 Traceback (most recent call last)
    <ipython-input-53-aa60172c3e3b> in <module>()
    ----> 1 f = "notes.txt", ignore_zeros = False )

    /usr/lib/python3.7/ in open(cls, name, mode, fileobj, bufsize, **kwargs)
       1577                     continue
    -> 1578             raise ReadError("file could not be opened successfully")
       1580         elif ":" in mode:

    ReadError: file could not be opened successfully

However, when specifying ignore_zeros = True, this check against invalid data seems to be turned off. Note that it is >invalid< data not >zero< data and therefore should still raise an exception! "foo.txt", ignore_zeros = True )

Iterating over that opened tarfile also works without exception however nothing will be iterated over, i.e., it behaves like an empty TAR instead of like an invalid TAR.
Date User Action Args
2020-05-24 18:10:44mxmlnkncreate