classification
Title: Exclusive mode for ZipFile and TarFile
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Antony.Lee, berker.peksag, lars.gustaebel, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2014-06-11 10:26 by Antony.Lee, last changed 2015-03-25 08:11 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
issue21717_tarfile.diff berker.peksag, 2014-06-23 14:23 review
issue21717_v2.diff berker.peksag, 2015-02-06 11:22 review
zipfile_mode_x.patch serhiy.storchaka, 2015-02-06 16:37 review
issue21717_tarfile_v3.diff berker.peksag, 2015-02-10 11:24 review
issue21717_tarfile_v4.diff berker.peksag, 2015-02-11 12:44 review
issue21717_tarfile_v5.diff berker.peksag, 2015-02-12 19:47 review
Messages (12)
msg220249 - (view) Author: Antony Lee (Antony.Lee) * Date: 2014-06-11 10:26
I noticed that while lzma and bz2 already support the "x" (create a new file, raise if it already exists) flag, zipfile and tarfile don't know about it yet.  It would be an useful addition, just as it is useful for regular open.

A quick look at both modules show that this likely only requires a little bit more than updating the checks in the corresponding constructors to allow "x" mode, as the modes are passed (nearly) transparently to the open() builtin.
msg221358 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2014-06-23 14:23
Here's a patch for tarfile.
msg235454 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-02-05 21:27
Ping.
msg235478 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-02-06 11:22
Here's an updated patch. Thanks Serhiy.
msg235482 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-02-06 13:29
Added more comments.
msg235488 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-02-06 16:37
Here is a patch for zipfile.
msg235679 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-02-10 11:24
Updated patch. Thanks again, Serhiy.
msg235912 - (view) Author: Roundup Robot (python-dev) Date: 2015-02-13 19:01
New changeset ed9e9e6b3c1e by Berker Peksag in branch 'default':
Issue #21717: tarfile.open() now supports 'x' (exclusive creation) mode.
https://hg.python.org/cpython/rev/ed9e9e6b3c1e
msg235913 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-02-13 19:04
Thanks for the review, Serhiy. I'll take a look at the zipfile patch tomorrow.
msg239149 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-03-24 16:19
Could you look on zipfile patch Berker? It is simpler than tarfile patch.
msg239231 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2015-03-25 07:42
LGTM. I left two minor comments on Rietveld. Sorry for the delay.
msg239235 - (view) Author: Roundup Robot (python-dev) Date: 2015-03-25 08:10
New changeset b2a8c30d8ddb by Serhiy Storchaka in branch 'default':
Issue #21717: The zipfile.ZipFile.open function now supports 'x' (exclusive
https://hg.python.org/cpython/rev/b2a8c30d8ddb
History
Date User Action Args
2015-03-25 08:11:46serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: commit review -> resolved
2015-03-25 08:10:26python-devsetmessages: + msg239235
2015-03-25 07:42:43berker.peksagsetmessages: + msg239231
stage: patch review -> commit review
2015-03-24 16:19:45serhiy.storchakasetassignee: serhiy.storchaka
messages: + msg239149
2015-02-13 19:04:36berker.peksagsetmessages: + msg235913
2015-02-13 19:01:58python-devsetnosy: + python-dev
messages: + msg235912
2015-02-12 19:47:03berker.peksagsetfiles: + issue21717_tarfile_v5.diff
2015-02-11 12:44:57berker.peksagsetfiles: + issue21717_tarfile_v4.diff
2015-02-10 11:24:42berker.peksagsetfiles: + issue21717_tarfile_v3.diff

messages: + msg235679
2015-02-06 16:37:47serhiy.storchakasetfiles: + zipfile_mode_x.patch

messages: + msg235488
2015-02-06 13:29:32serhiy.storchakasetmessages: + msg235482
2015-02-06 11:22:27berker.peksagsetfiles: + issue21717_v2.diff

messages: + msg235478
2015-02-05 21:27:06serhiy.storchakasetmessages: + msg235454
2014-06-23 14:23:14berker.peksagsetfiles: + issue21717_tarfile.diff

type: enhancement
versions: - Python 3.4
keywords: + patch
nosy: + berker.peksag, serhiy.storchaka, lars.gustaebel

messages: + msg221358
stage: patch review
2014-06-11 10:26:20Antony.Leecreate