bpo-44289: Keep argument file object's current position in tarfile.is_tarfile (GH-26488)

This commit is contained in:
Andrzej Mateja 2022-02-09 17:19:16 +01:00 committed by GitHub
parent d2d1d49eac
commit 128ab092ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View file

@ -2493,7 +2493,9 @@ def is_tarfile(name):
"""
try:
if hasattr(name, "read"):
pos = name.tell()
t = open(fileobj=name)
name.seek(pos)
else:
t = open(name)
t.close()