[issue44289] tarfile.is_tarfile() and tarfile.open() when used with file object may cause tarfile operations to fail

Andrei Kulakov report at bugs.python.org
Wed Dec 8 20:23:31 EST 2021


Andrei Kulakov <andrei.avk at gmail.com> added the comment:

This affects more use cases than just is_tarfile() and getmembers() results.

is_tarfile() calls open() which is the root cause of the issue. Calling open() 2+ times will also cause the same issue.

In addition to getmembers(), extracting the tar will also silently fail. (and possibly other operations).

I've suggested a different fix in the comment on the PR:
https://github.com/python/cpython/pull/26488#issuecomment-989367707

----------
nosy: +andrei.avk
title: tarfile.is_tarfile() modifies file object's current position -> tarfile.is_tarfile() and tarfile.open() when used with file object may cause tarfile operations to fail

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44289>
_______________________________________


More information about the Python-bugs-list mailing list