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: zipfile "append" mode should create a file if not present
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gregory.p.smith, krumms, loewis, riteshsarraf
Priority: normal Keywords:

Created on 2006-06-29 16:42 by riteshsarraf, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg28975 - (view) Author: Ritesh Raj Sarraf (riteshsarraf) Date: 2006-06-29 16:42
The line 

filename = zipfile.ZipFile(zip_file_name, "a") 

throws an exception if the given filename is not 
present already.

Shouldn't it create a file (in case one is not there) 
since it is "append" mode ??

It's throwing an OSError Exception stating "No such 
file/directory".

Normal convention has been that when opening a file 
in append mode, if the file is not present a new file 
is created.

Why is this non-standard?
msg28976 - (view) Author: Thomas Lee (krumms) (Python committer) Date: 2006-07-06 02:31
Logged In: YES 
user_id=315535

Patch #1517891 resolves this. See:

http://sourceforge.net/tracker/index.php?func=detail&aid=1517891&group_id=5470&atid=305470

Waiting for review.
msg28977 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2006-07-08 17:38
Logged In: YES 
user_id=413

I agree.  append semantics generally mean append or create.

+1 from me on fixing this bug.

if any existing code is depending on the side effect from
opening a zip file in 'a' mode to tell them that it doesn't
already exist this change would break that; but I'd argue
that such code is already broken and should be cleaned up.
msg28978 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-02-13 10:10
Technically, this is not a bug, as the documentation clearly states that 'a' should open existing files.
For 2.6, the behavior is changed with said patch.
History
Date User Action Args
2022-04-11 14:56:18adminsetgithub: 43574
2006-06-29 16:42:46riteshsarrafcreate