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.

classification
Title: tarfile.open(mode = 'r:*', ignore_zeros = True) has 50% chance failed to open compressed tars?
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7, Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: RoliSoft, Silver Fox, lars.gustaebel, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2016-10-15 09:07 by Silver Fox, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tarfile_ignore_zeros_auto.patch serhiy.storchaka, 2016-10-16 17:16 review
Pull Requests
URL Status Linked Edit
PR 552 closed dstufft, 2017-03-31 16:36
Messages (4)
msg278711 - (view) Author: Silver Fox (Silver Fox) Date: 2016-10-15 09:07
Seems all `tarfile.open` will try all compress method(including `raw`) in random order, and `ignore_zeros` also hide the error during detecting compress method. So `raw` is used if tested before the rigth compress method, which is wrong.

But there is no warning that the 2 args can not be used together in docs.
msg278767 - (view) Author: Roland Bogosi (RoliSoft) Date: 2016-10-16 12:36
For anyone finding this bug through Google before it is fixed, a workaround could be to monkeypatch the OPEN_METH dict with an OrderedDict:

	tarfile.TarFile.OPEN_METH = OrderedDict()
	tarfile.TarFile.OPEN_METH['gz']  = 'gzopen'
	tarfile.TarFile.OPEN_METH['bz2'] = 'bz2open'
	tarfile.TarFile.OPEN_METH['xz']  = 'xzopen'
	tarfile.TarFile.OPEN_METH['tar'] = 'taropen'
msg278773 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-10-16 17:16
Proposed patch fixes the issue.

Existing test was passed by accident -- compressed tarfiles were too short for false detecting.
msg279740 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-10-30 18:59
New changeset f108e063e299 by Serhiy Storchaka in branch '3.5':
Issue #28449: tarfile.open() with mode "r" or "r:" now tries to open a tar
https://hg.python.org/cpython/rev/f108e063e299

New changeset e2dd0f48e643 by Serhiy Storchaka in branch '2.7':
Issue #28449: tarfile.open() with mode "r" or "r:" now tries to open a tar
https://hg.python.org/cpython/rev/e2dd0f48e643

New changeset de8e83262644 by Serhiy Storchaka in branch '3.6':
Issue #28449: tarfile.open() with mode "r" or "r:" now tries to open a tar
https://hg.python.org/cpython/rev/de8e83262644

New changeset 220c70519958 by Serhiy Storchaka in branch 'default':
Issue #28449: tarfile.open() with mode "r" or "r:" now tries to open a tar
https://hg.python.org/cpython/rev/220c70519958
History
Date User Action Args
2022-04-11 14:58:38adminsetgithub: 72635
2017-03-31 16:36:31dstufftsetpull_requests: + pull_request1046
2016-10-30 18:59:50serhiy.storchakasetstatus: open -> closed
assignee: serhiy.storchaka
resolution: fixed
stage: patch review -> resolved
2016-10-30 18:59:06python-devsetnosy: + python-dev
messages: + msg279740
2016-10-16 17:16:52serhiy.storchakasetfiles: + tarfile_ignore_zeros_auto.patch

nosy: + serhiy.storchaka
messages: + msg278773

keywords: + patch
stage: patch review
2016-10-16 12:36:04RoliSoftsetnosy: + RoliSoft
messages: + msg278767
2016-10-15 09:51:33serhiy.storchakasetnosy: + lars.gustaebel

versions: + Python 2.7, Python 3.6, Python 3.7, - Python 3.4
2016-10-15 09:07:44Silver Foxcreate