'ZipFile producing empty files on 'append' mode

I'm getting inconsistent behaviors when a ZipFile is created from a file with 'a'ppend or 'w'rite mode:

from zipfile import ZipFile

with ZipFile(open('tempdir/a.zip', 'ab+'), 'a') as z:
    z.writestr('file.txt', 'z'*100)
# file.txt is empty inside a.zip.

with ZipFile(open('tempdir/w.zip', 'wb+'), 'a') as z:
    z.writestr('file.txt', 'z'*100)
# file.txt has correct contents inside w.zip.

Shouldn't 'append' and 'write' modes be equivalent in this case? The files don't exist beforehand, and I expected 'a.zip' to contain a non-empty 'file.txt'.

This happens on Windows 10, Python 3.6, 64 bit.

Edit: couldn't reproduce this issue on [Windows 10, Python 3.3.5, 32 bit] or [Windows 10 Bash, Python 3.4.3, 64 bit].



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source