Skip to content

Fix OverlayStream read-to-EOF without a known size - #136

Open
alan-divd wants to merge 1 commit into
fox-it:mainfrom
alan-divd:fix/overlay-stream-no-size
Open

alan-divd wants to merge 1 commit into
fox-it:mainfrom
alan-divd:fix/overlay-stream-no-size

Conversation

@alan-divd

Copy link
Copy Markdown

Summary

Reading to EOF on an OverlayStream with no known size used sys.maxsize as
the read length. That works on a BytesIO, but a real file object raises
OverflowError: byte string is too large.

Determine the actual end instead, by seeking the source to EOF and taking the
maximum of that and the end of every registered overlay, so an overlay that
extends past the end of the source stream is still fully read.

Fixes #114

Test plan

  • tox run -e py3 passes (161 passed)
  • The new test wraps a BytesIO in an io.BufferedReader so the
    OverflowError reproduces in memory, matching how the existing tests
    avoid touching the filesystem
  • Covers an overlay that extends past the end of the source stream

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Read on OverlayStream without a known size fails

1 participant