-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
ValueError in zipfile.ZipFile #83245
Comments
The attached file produces the following stacktrace when opened via
The ValueError exception isn't documented as a possible exception when using zipfile.ZipFile ( https://docs.python.org/3/library/tarfile.html ). |
It's unlikely that anyone will download a binary from bpo and open it. Can you help us reproduce the issue without that? First question is whether you can reproduce this on a version of python that is still in maintenance - 3.9 or higher? |
Yes, I can reproduce it:
The binary is a corrupted zip file to open with |
It's easy enough to convert the exception type (see patch), but I don't know how to write a unit test for this. |
Try to create a normal ZIP file (it can be empty), then try to set some byte to FF (or a pair of bytes to FFFF, or 4 consequent bytes to FFFFFFFF, until you get the exactly same error). Then you can just add the binary dump of that file in tests. |
One way of doing this is by making the central directory offset negative by first taking the zip file containing just an EOCD record and then listing the total size of the central directory records as positive.
|
Sam, can you put that in a PR please? |
Yes, of course. |
…pt ZIP file (GH-32291) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
… corrupt ZIP file (pythonGH-32291) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit 202ed25) Co-authored-by: Sam Ezeh <sam.z.ezeh@gmail.com>
… corrupt ZIP file (pythonGH-32291) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> (cherry picked from commit 202ed25) Co-authored-by: Sam Ezeh <sam.z.ezeh@gmail.com>
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: