[issue30282] object returned by tarfile.extractfile has an incorrect value of name attribute

Ondrej Kubecka report at bugs.python.org
Fri May 5 11:09:35 EDT 2017


New submission from Ondrej Kubecka:

Consider the following code snippet:

<snip>
import tarfile

tar1 = tarfile.open('tar1.tar.gz')
file_ = tar1.extractfile('FILE')
print(file_.name)
</snip>

Up until 3.2.x, the value of name attribute would be 'FILE' as derived from tarinfo of the member. Starting with 3.3 (commits: b062a2fa 7a919e99) this value be obtained from tarfile.fileobj ("parent" tarball file) and would return 'tar1.tar.gz' instead.

This does not seem to be correct as it's not a filename of the ExFileObject / _FileInFile / io.BufferedReader object itself which would otherwise be consistent with values normally found under name.

There is also a problem that this information no longer appears to be accessible at all looking at the object returned from extractfile alone.

And looking at release notes of 3.3, this does not seem to be intentional effect.

----------
components: Library (Lib)
messages: 293111
nosy: Ondrej Kubecka
priority: normal
severity: normal
status: open
title: object returned by tarfile.extractfile has an incorrect value of name attribute
type: behavior
versions: Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30282>
_______________________________________


More information about the Python-bugs-list mailing list