-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
bpo-4833: Add ZipFile.mkdir #32160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-4833: Add ZipFile.mkdir #32160
Conversation
@@ -1783,23 +1784,6 @@ def write(self, filename, arcname=None, | |||
else: | |||
zinfo._compresslevel = self.compresslevel | |||
|
|||
if zinfo.is_dir(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that write
can no longer be used to create a directory? I suspect that will break existing code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was marked as resolved, but I do not see an answer to my question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think write still accepts directory zinfo, now it’s handled on line 1775 by calling mkdir instead of directly inline here.
There should be a test for write + directory; if not, then this PR needs to add one!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right -- 1175 does handle that. Thanks!
A fairly quick scan of the tests doesn't reveal one using .write(some_directory/
). @dignissimus please confirm such a test already exists, or add one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very thorough PR. Question in-line.
interesting, since it is also possible to imply directories (if there is a file in there) but this would allow an empty directory |
@dignissimus : ping me in a few days if no one has merged this yet -- I want to give other folks the chance to review. |
@dignissimus Actually, I forgot: have you either verified or added a test for creating a directory using the existing |
@ethanfurman The tests have been added! |
Add
ZipFile.mkdir
method to create directories inside zip archives.https://bugs.python.org/issue4833