Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-84481: Add ZipFile.data_offset attribute#132165
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This attribute provides the offset to zip data from the start of the file, when available.
python-cla-botbot commentedApr 6, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I have signed the CLA with my current email. (I had already signed it under another email anyway) |
0788948 intopython:mainUh oh!
There was an error while loading.Please reload this page.
| self.fp=_Tellable(self.fp) | ||
| self.start_dir=0 | ||
| self._seekable=False | ||
| self._data_offset=None |
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.
It may not be set ifmode == 'a' and ifBadZipFile is raised. In this case, we should still have aNone according to the docs (otherwise an AttributeError will be raised).
For mode 'r', it should be noted that failing_RealGetContents() means that the object will never be initialized so we don't care about the lack of attribute.
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 believe that in this case, since mode 'a' callstell() unconditionally, we can set thedata_offset to the result of that, right?
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.
Though honestly the defensive thing to do here is to initialize it to None early on then change it later when possible.
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.
Though honestly the defensive thing to do here is to initialize it to None early on then change it later when possible.
Yes, that's what I thought.
* Add ZipFile.data_offset attributeThis attribute provides the offset to zip data from the start of the file, when available.* Add blurb-it* Try fixing class ref in NEWS
)"This reverts commit0788948.
* Revert "pythongh-84481: Make ZipFile.data_offset more robust (pythonGH-132178)"This reverts commit6cd1d6c.* Revert "pythongh-84481: Add ZipFile.data_offset attribute (pythonGH-132165)"This reverts commit0788948.---------(cherry picked from commit6bf1c0a)Co-authored-by: Emma Smith <emma@emmatyping.dev>Co-authored-by: Gregory P. Smith <greg@krypto.org>
…36955)gh-136170: Revert adding `ZipFile.data_offset` (GH-136950)* Revert "gh-84481: Make ZipFile.data_offset more robust (GH-132178)"This reverts commit6cd1d6c.* Revert "gh-84481: Add ZipFile.data_offset attribute (GH-132165)"This reverts commit0788948.---------(cherry picked from commit6bf1c0a)Co-authored-by: Emma Smith <emma@emmatyping.dev>Co-authored-by: Gregory P. Smith <greg@krypto.org>
* Revert "pythongh-84481: Make ZipFile.data_offset more robust (python#132178)"This reverts commit6cd1d6c.* Revert "pythongh-84481: Add ZipFile.data_offset attribute (python#132165)"This reverts commit0788948.---------Co-authored-by: Gregory P. Smith <greg@krypto.org>
* Revert "pythongh-84481: Make ZipFile.data_offset more robust (python#132178)"This reverts commit6cd1d6c.* Revert "pythongh-84481: Add ZipFile.data_offset attribute (python#132165)"This reverts commit0788948.---------Co-authored-by: Gregory P. Smith <greg@krypto.org>
…-136950) (python#136955)pythongh-136170: Revert adding `ZipFile.data_offset` (pythonGH-136950)* Revert "pythongh-84481: Make ZipFile.data_offset more robust (pythonGH-132178)"This reverts commit6cd1d6c.* Revert "pythongh-84481: Add ZipFile.data_offset attribute (pythonGH-132165)"This reverts commit0788948.---------(cherry picked from commit6bf1c0a)Co-authored-by: Emma Smith <emma@emmatyping.dev>Co-authored-by: Gregory P. Smith <greg@krypto.org>
Uh oh!
There was an error while loading.Please reload this page.
This attribute provides the offset to zip data from the start of the file, when available.
I chose
data_offsetto avoid confusion with the_offsetproperty that is unrelated.📚 Documentation preview 📚:https://cpython-previews--132165.org.readthedocs.build/