[issue45006] Add data_offset field to ZipInfo

Ammar Askar report at bugs.python.org
Wed Oct 6 11:22:47 EDT 2021


Ammar Askar <ammar at ammaraskar.com> added the comment:

Could you explain your use-case for this feature in a bit more detail? zipfile is meant to be a relatively high level library to do common tasks such as reading/writing/listing files.

The use case for `data_offset` proposed here seems to be relatively advanced and I don't see how it would be to useful for the vast majority of users.


(Without adding to the public API, I think you can achieve a pretty similar functionality by using the following)

compressed_data = zipfile.open(zipinfo)._read2(compressed_size)

Obviously, this relies on undocumented internals, but for a niche use case that might not be the worst thing: https://github.com/python/cpython/blob/61892c04764e1f3a659bbd09e6373687a27d36e2/Lib/zipfile.py#L1042-L1056

----------
nosy: +ammar2

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45006>
_______________________________________


More information about the Python-bugs-list mailing list