Conversation
|
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
|
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
76722fa to
f3450f1
Compare
|
Automatically compacting the
The latter method is dangerous for self-extracting |
|
Also, please don't force-push to an open PR. It makes it harder for reviewers to follow changes! Thanks |
* Add remove method to ZipFile Refer to: python/cpython#103033 * Make use of `ZipFileWithRemove`
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
This is a revision of commit 659eb04 (PR python#19358), notably with following changes: - Add documentation and tests. - Raise `ValueError` for a bad mode, as in other methods. - Support multi-member removal in `_remove_members()`. - Support non-physical removal in `_remove_members()`. - Move physical file data in chunks to prevent excessive memory usage on large files. - Fix missing entry in `self.NameToInfo` when removing a duplicated archive name. - Also update `ZipInfo._end_offset` for physically moved files. Co-authored-by: Éric <merwok@netwok.org> (cherry picked from commit e6bc82a (PR python#103033))
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
This is a revision of commit 659eb04 (PR python#19358), notably with following changes: - Add documentation and tests. - Raise `ValueError` for a bad mode, as in other methods. - Support multi-member removal in `_remove_members()`. - Support non-physical removal in `_remove_members()`. - Move physical file data in chunks to prevent excessive memory usage on large files. - Fix missing entry in `self.NameToInfo` when removing a duplicated archive name. - Also update `ZipInfo._end_offset` for physically moved files. Co-authored-by: Éric <merwok@netwok.org> (cherry picked from commit e6bc82a (PR python#103033))
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
ZipFile.remove()
|
The PR is being old and the base python executable can be hardly compiled. Rebased onto the latest Python and make sure it builds, with few trivial commits squashed together. |
| @@ -0,0 +1 @@ | |||
| Add ``ZipFile.remove()`` | |||
There was a problem hiding this comment.
| Add ``ZipFile.remove()`` | |
| Add :meth:`ZipFile.remove <zipfile.ZipFile.remove>`. |
This is a revision of commit 659eb04 (PR python#19358), notably with following changes: - Add documentation and tests. - Raise `ValueError` for a bad mode, as in other methods. - Support multi-member removal in `_remove_members()`. - Support non-physical removal in `_remove_members()`. - Move physical file data in chunks to prevent excessive memory usage on large files. - Fix missing entry in `self.NameToInfo` when removing a duplicated archive name. - Also update `ZipInfo._end_offset` for physically moved files. Co-authored-by: Éric <merwok@netwok.org> (cherry picked from commit e6bc82a (PR python#103033))
- File is not truncated in mode 'w'/'x', which results non-shrinked file. - This cannot be simply resolved by adding truncation for mode 'w'/'x', which may be used on an unseekable file buffer and truncation is not allowed.
- The seek will be automatically called in `ZipFile.close`.
|
Rebased to use the same base as PR #134627 for easier comparison. In favor of #134627, I'm probably not going to keep working on this PR, unless it proves to be the final accepted approach for the issue. NOTE: Compared to #134627, this PR is rather quick and naive, and some cares may need to be aware of:
Unfortunately, fixing any of them requires a non-trivial code rework. |
This is a revision of #19358 (for issue #51067) as the original author seems not keeping working.
Notable changes:
Added docs and tests.
Support mode 'w' and 'x', as noted by remove/delete method for zipfile objects #51067 (comment)
Support removing multiple members and removing non-physically with the internal
_remove_membersmethod, as they may be used by some interested people, as noted by remove/delete method for zipfile objects #51067 (comment) and remove/delete method for zipfile objects #51067 (comment).They are not currently introduced in the public
removeAPI, as it would involve more complicated changes to the public APIs (e.g. introducing error handling for multiple members, and a extra method that purges stale data by non-physical removing) and other ZipFile related APIs do not support similar operations.Move physical data in chunks, to prevent a memory issue for large files.
Fixed a flaw of the previous implementation that
self.NameToInfogets a missing key when removing one of duplicated arcnames.📚 Documentation preview 📚: https://cpython-previews--103033.org.readthedocs.build/