Skip to content

Commit 5f093e5

Browse files
committed
1 parent ce88616 commit 5f093e5

File tree

4 files changed

+827
-338
lines changed

4 files changed

+827
-338
lines changed

Doc/library/zipfile.rst

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -526,9 +526,8 @@ ZipFile Objects
526526
If multiple members share the same full path, only one is removed when
527527
a path is provided.
528528

529-
This does not physically remove the local file entry from the archive;
530-
the ZIP file size remains unchanged. Call :meth:`ZipFile.repack` afterwards
531-
to reclaim space.
529+
This does not physically remove the local file entry from the archive.
530+
Call :meth:`ZipFile.repack` afterwards to reclaim space.
532531

533532
The archive must be opened with mode ``'w'``, ``'x'`` or ``'a'``.
534533

@@ -542,30 +541,32 @@ ZipFile Objects
542541
.. method:: ZipFile.repack(removed=None, *, \
543542
strict_descriptor=False[, chunk_size])
544543

545-
Rewrites the archive to remove stale local file entries, shrinking the ZIP
546-
file size.
544+
Rewrites the archive to remove stale local file entries, shrinking its file
545+
size.
547546

548547
If *removed* is provided, it must be a sequence of :class:`ZipInfo` objects
549548
representing removed entries; only their corresponding local file entries
550549
will be removed.
551550

552-
If *removed* is not provided, local file entries no longer referenced in the
553-
central directory will be removed. The algorithm assumes that local file
554-
entries are stored consecutively:
551+
If *removed* is not provided, the archive is scanned to identify and remove
552+
local file entries that are no longer referenced in the central directory.
553+
The algorithm assumes that local file entries (and the central directory,
554+
which is mostly treated as the "last entry") are stored consecutively:
555555

556556
#. Data before the first referenced entry is removed only when it appears to
557557
be a sequence of consecutive entries with no extra following bytes; extra
558-
preceeding bytes are preserved.
558+
preceding bytes are preserved.
559559
#. Data between referenced entries is removed only when it appears to
560560
be a sequence of consecutive entries with no extra preceding bytes; extra
561561
following bytes are preserved.
562-
563-
``strict_descriptor=True`` can be provided to skip the slower scan for an
564-
unsigned data descriptor (deprecated in the latest ZIP specification and is
565-
only used by legacy tools) when checking for bytes resembling a valid local
566-
file entry. This improves performance, but may cause some stale local file
567-
entries to be preserved, as any entry using an unsigned descriptor cannot
568-
be detected.
562+
#. Entries must not overlap. If any entry's data overlaps with another, a
563+
:exc:`BadZipFile` error is raised and no changes are made.
564+
565+
When scanning, setting ``strict_descriptor=True`` disables detection of any
566+
entry using an unsigned data descriptor (deprecated in the ZIP specification
567+
since version 6.3.0, released on 2006-09-29, and used only by some legacy
568+
tools). This improves performance, but may cause some stale entries to be
569+
preserved.
569570

570571
*chunk_size* may be specified to control the buffer size when moving
571572
entry data (default is 1 MiB).

0 commit comments

Comments
 (0)