On 5/23/26 21:38, Bill Barry wrote:
On Sat, May 23, 2026 at 4:05 PM Galen Seitz <[email protected]> wrote:
...
It's still not clear to me why the 2nd call to create_dst doesn't fail, but it is clear that I need to use copy.copy.The 2nd call did not fail because of luck. The header_offset for foot.txt in src.zip is 0 and the header_offset that it wrote it to in dst0.zip was also 0. The creation of dst0.zip overwrote the header_offset but it overwrote it with the same value. The 4th call is not so lucky. info = src_zip.getinfo("bar.txt") reads the header_offset from a dictionary as 44. Then the creation of dst3.zip writes bar.text to the beginning of dst3.zip with header_offset 0 and overwrites the object in the dictionary. The next time that info=src_ziop.getinfo("bar.txt") is called it gets the overwritten value of 0, not the correct value of 44. It looks in the zip file at offset 0 for bar.txt and sees that it is not bar.txt but foo.txt and gives up.
Thanks for the explanation. I see now that the calls involving foo.txt worked because foo.txt was located at the same position in both the src and dst zip. As soon as this is no longer true, it's going to fail due to the sharing of header_offset.
galen -- Galen Seitz [email protected]
