This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author progval
Recipients progval
Date 2022-03-04.16:43:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1646412209.92.0.374671819607.issue46922@roundup.psfhosted.org>
In-reply-to
Content
Hi,

I found two related bugs when calling tarfile.TarFile.next() on an empty tar file, both when trying to seek when it should not:

import io
import tarfile

# Create a tarball with no member:
fd = io.BytesIO()
with tarfile.open(fileobj=fd, mode="w") as tf:
    pass

# read in stream mode:
fd.seek(0)
with tarfile.open(fileobj=fd, mode="r|") as tf:
    print(tf.next())   # tarfile.StreamError: seeking backwards is not allowed

# read in normal mode:
fd.seek(0)
with tarfile.open(fileobj=fd, mode="r") as tf:
    print(tf.next())  # ValueError: negative seek value -1
History
Date User Action Args
2022-03-04 16:43:29progvalsetrecipients: + progval
2022-03-04 16:43:29progvalsetmessageid: <1646412209.92.0.374671819607.issue46922@roundup.psfhosted.org>
2022-03-04 16:43:29progvallinkissue46922 messages
2022-03-04 16:43:29progvalcreate