Issue 28449: tarfile.open(mode = 'r:*', ignore_zeros = True) has 50% chance failed to open compressed tars? (original) (raw)

Issue28449

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:38 admin set github: 72635
2017-03-31 16:36:31 dstufft set pull_requests: + <pull%5Frequest1046>
2016-10-30 18:59:50 serhiy.storchaka set status: open -> closedassignee: serhiy.storchakaresolution: fixedstage: patch review -> resolved
2016-10-30 18:59:06 python-dev set nosy: + python-devmessages: +
2016-10-16 17:16:52 serhiy.storchaka set files: + tarfile_ignore_zeros_auto.patchnosy: + serhiy.storchakamessages: + keywords: + patchstage: patch review
2016-10-16 12:36:04 RoliSoft set nosy: + RoliSoftmessages: +
2016-10-15 09:51:33 serhiy.storchaka set nosy: + lars.gustaebelversions: + Python 2.7, Python 3.6, Python 3.7, - Python 3.4
2016-10-15 09:07:44 Silver Fox create