Title: Empty read from gitdb.OStream.read() before EOF · Issue #120 · gitpython-developers/gitdb · GitHub
Open Graph Title: Empty read from gitdb.OStream.read() before EOF · Issue #120 · gitpython-developers/gitdb
X Title: Empty read from gitdb.OStream.read() before EOF · Issue #120 · gitpython-developers/gitdb
Description: I have code that relies on reading an object from a gitdb stream. To do this I used with a standard .read() loop (like with io.RawIOBase): stream = db.stream(bytes.fromhex(sha)) while chunk := stream.read(4096): yield chunk The behaviour...
Open Graph Description: I have code that relies on reading an object from a gitdb stream. To do this I used with a standard .read() loop (like with io.RawIOBase): stream = db.stream(bytes.fromhex(sha)) while chunk := stre...
X Description: I have code that relies on reading an object from a gitdb stream. To do this I used with a standard .read() loop (like with io.RawIOBase): stream = db.stream(bytes.fromhex(sha)) while chunk := stre...
Opengraph URL: https://github.com/gitpython-developers/gitdb/issues/120
X: @github
Domain: togithub.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Empty read from gitdb.OStream.read() before EOF","articleBody":"I have code that relies on reading an object from a gitdb stream.\n\nTo do this I used with a standard `.read()` loop (like with [io.RawIOBase](https://docs.python.org/3/library/io.html#io.RawIOBase)):\n\n```python\nstream = db.stream(bytes.fromhex(sha))\nwhile chunk := stream.read(4096):\n yield chunk\n```\n\nThe behaviour I expected to see (from the duck-type with RawIOBase) is to only see `b''` at EOF:\n\n\u003e If 0 bytes are returned, and size was not 0, this indicates end of file. \n\nHowever `stream.read(4096)` can return empty chunks even before the end of the stream, so the loop exits early.\n\nFor the file where I saw this first, it is sensitive to the `size` parameter - it apparently occurs for `0 \u003c size \u003c= 4096`.\n\nLooking at the code there is a condition to repeat a read if we got insufficient bytes:\n\nhttps://github.com/gitpython-developers/gitdb/blob/f36c0cc42ea2f529291e441073f74e920988d4d2/gitdb/stream.py#L316-L317\n\nHowever the leading `if dcompdat and ` means that the condition doesn't apply if zero bytes were read. Removing this part of the condition addresses the issue (but I understand from the comment that this is in order to support `compressed_bytes_read()`).","author":{"url":"https://github.com/lordmauve","@type":"Person","name":"lordmauve"},"datePublished":"2025-04-16T10:35:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/120/gitdb/issues/120"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4c6ee7e1-74bb-f3de-e295-5f93240de9c1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AF26:3DE9D:B4426:F129E:6969403C |
| html-safe-nonce | 8945d4db23dab07c5adea64711a6ca0ce49fce09a73d9f051700160df56388e5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjI2OjNERTlEOkI0NDI2OkYxMjlFOjY5Njk0MDNDIiwidmlzaXRvcl9pZCI6IjE4MDI3MTc3ODU4NzU4OTAyMzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0e22b9e9e58b6e9f3e09d3be5ed799d116ea505b96cf31a76d1436c1fb959f95 |
| hovercard-subject-tag | issue:2999218306 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/gitdb/120/issue_layout |
| twitter:image | https://opengraph.githubassets.com/79f6d87f930bb8f908f8a26c95555a0b819fa6cacea7e23cec4b27a3a734e87d/gitpython-developers/gitdb/issues/120 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/79f6d87f930bb8f908f8a26c95555a0b819fa6cacea7e23cec4b27a3a734e87d/gitpython-developers/gitdb/issues/120 |
| og:image:alt | I have code that relies on reading an object from a gitdb stream. To do this I used with a standard .read() loop (like with io.RawIOBase): stream = db.stream(bytes.fromhex(sha)) while chunk := stre... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lordmauve |
| hostname | github.com |
| expected-hostname | github.com |
| None | 54182691a21263b584d2e600b758e081b0ff1d10ffc0d2eefa51cf754b43b51d |
| turbo-cache-control | no-preview |
| go-import | github.com/gitpython-developers/gitdb git https://github.com/gitpython-developers/gitdb.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126093 |
| octolytics-dimension-repository_nwo | gitpython-developers/gitdb |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126093 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/gitdb |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d69ac0477df0f87da03b8b06cebd187012d7a930 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width