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
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee=Noneclosed_at=Nonecreated_at=<Date2021-06-02.15:09:05.223>labels= ['type-bug', 'library', '3.9', '3.10', '3.11']
title='tarfile.is_tarfile() and tarfile.open() when used with file object may cause tarfile operations to fail'updated_at=<Date2022-02-09.16:19:26.161>user='https://github.com/amateja'
Since Python 3.9 tarfile.is_tarfile accepts not only paths but also files and file-like objects (bpo-29435).
Verification if a file or file-like object is a tar file modifies file object's current position.
Imagine a function listing names of all tar archive members but checking first if this is a valid tar archive. When its argument is a str or pathlib.Path this is quite straightforward. If the argument is a file of file-like object then current position must be reset or TarFile.getmembers() returns empty list.