Skip to content

Fix typo - #120

Closed
jet-sun wants to merge 1 commit into
gitpython-developers:0.3from
jet-sun:patch-1
Closed

Fix typo#120
jet-sun wants to merge 1 commit into
gitpython-developers:0.3from
jet-sun:patch-1

Conversation

@jet-sun

@jet-sun jet-sun commented Sep 19, 2013

Copy link
Copy Markdown

No description provided.

@Byron

Byron commented Nov 17, 2014

Copy link
Copy Markdown
Member

Thank you - I will fix typos as I encounter them for the upcoming release.
As this commit only contains a single fix and auto-merge is not possible, I will not go through the overhead of merging it.
Thanks for your understanding.

@Byron Byron closed this Nov 17, 2014
govtech42 pushed a commit to mirror81/GitPython that referenced this pull request Jul 25, 2026
Closes gitpython-developers#120

DecompressMemMapReader.read(N) could return b'' mid-stream when zlib
consumed input without producing output on a single decompress call
(small N, header / dictionary frames in flight). The original
`if dcompdat and ...` guard at the recursion site skipped the
"refill to size" recursion in that case, so a caller using the
standard idiom

    while chunk := stream.read(4096):
        yield chunk

terminated at the first empty chunk -- before _br == _s.

The guard exists for compressed_bytes_read(), which manipulates
_br=0 and then drains the inner zip past its EOF. Recursing there
would loop forever because the inner zip is already done.

The fix uses zlib's own `eof` attribute (available on standard
zlib.Decompress objects since Python 3.6) to distinguish:

  - dcompdat empty AND zip not at EOF -> still digesting, recurse
  - dcompdat empty AND zip at EOF      -> compressed_bytes_read
                                         scrub or genuine EOF; do
                                         not recurse.

`getattr(_zip, 'eof', False)` keeps the conservative behavior
when running against a custom zlib object that does not expose
the attribute.

Adds a regression test that reads with chunk_size in
{1, 4, 16, 64} from a 13 KB highly-compressible stream. With the
old guard, the chunk_size <= 16 cases stopped at byte 0; the new
test asserts they read all 13000 bytes.

The full existing test suite (24 tests) still passes, including
test_decompress_reader_special_case and test_pack which exercise
the compressed_bytes_read scrub path that the original guard
existed to protect.
govtech42 pushed a commit to mirror81/GitPython that referenced this pull request Jul 25, 2026
…ty-read-before-eof

Fix DecompressMemMapReader.read returning b'' before EOF (gitpython-developers#120)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants