FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-51067: Remove trailing space in `_Repacker.repack()` error message by danny0838 · Pull Request #152138 · python/cpython · GitHub

Repository navigation

gh-51067: Remove trailing space in _Repacker.repack() error message - #152138

Merged
gpshead merged 1 commit into
python:mainfrom
danny0838:gh-51067-4
Oct 12, 2026
Merged

gpshead merged 1 commit into
python:mainfrom
danny0838:gh-51067-4

Conversation

danny0838 commented Jun 25, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

Remove an accidental trailing space inside the BadZipFile exception string literal to ensure clean exception messages.

…essage

Remove an accidental trailing space inside the `BadZipFile` exception
string literal to ensure clean exception messages.

Copy link
Copy Markdown
Member

In the future, it's fine to bundle several small clean-ups (like the de-deduplication) in one PR.

StanFromIreland requested a review from gpshead June 25, 2026 11:59

Copy link
Copy Markdown
Contributor Author

@StanFromIreland @gpshead Is there still any major concern about this PR?

FYI, this error was introduced because I forgot to remove the trailing space when copying the code snippet from the zip bomb check:

            if (zinfo._end_offset is not None and
                zef_file.tell() + zinfo.compress_size > zinfo._end_offset):
                if zinfo._end_offset == zinfo.header_offset:
                    import warnings
                    warnings.warn(
                        f"Overlapped entries: {zinfo.orig_filename!r} "
                        f"(possible zip bomb)",
                        skip_file_prefixes=(os.path.dirname(__file__),))
                else:
                    raise BadZipFile(
                        f"Overlapped entries: {zinfo.orig_filename!r} "
                        f"(possible zip bomb)")

I removed the "(possible zip bomb)" because it's irrelevant and may be improper here. The overlapping check here is against all ZipInfos in the ZipFile PLUS all ZipInfos passed by the removed argument for ZipFile.repack. It may happen on a normal ZIP archive when ZipInfos passed by removed are improper.

For example, when calling repack([m1]) and then repack([m2]) for a ZipFile with (m1, m2, m3) and has (m1, m2) removed, because m3 has been repositioned to a smaller offset in the prior repack and therefore overlaps with m2, which still records the original offset and size.

For another example, when calling repack([m1]) for a ZipFile with m1, m2, m3 and m1 is not removed.

We do can consider providing a more comprehensive hint, such as the offset or used size of the offensive member, but it may need much more considerations and I think we can do the clean first and left it to future enhancement.

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

github-actions Bot added the stale Stale PR or inactive for long period of time. label Oct 11, 2026
gpshead added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 12, 2026
gpshead merged commit aab474a into python:main Oct 12, 2026
104 of 106 checks passed

Copy link
Copy Markdown

Thanks @danny0838 for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

Copy link
Copy Markdown

Sorry, @danny0838 and @gpshead, I could not cleanly backport this to 3.15 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker aab474a35b7d47aa3404db0fd5cb2c0314090941 3.15

Copy link
Copy Markdown

Sorry, @danny0838 and @gpshead, I could not cleanly backport this to 3.14 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker aab474a35b7d47aa3404db0fd5cb2c0314090941 3.14

gpshead removed needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL