Title: GitHub · Where software is built
Open Graph Title: gitpython-developers/gitdb
X Title: gitpython-developers/gitdb
Description: IO of git-style object databases. Contribute to gitpython-developers/gitdb development by creating an account on GitHub.
Open Graph Description: IO of git-style object databases. Contribute to gitpython-developers/gitdb development by creating an account on GitHub.
X Description: IO of git-style object databases. Contribute to gitpython-developers/gitdb development by creating an account on GitHub.
Opengraph URL: https://github.com/gitpython-developers/gitdb
X: @github
Domain: redirect.github.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 | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:7bbb17f2-cfb0-9007-20be-6b16e2c42bbd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D0C4:14A586:20E2812:2E0A782:69693C9E |
| html-safe-nonce | ba21648fc04ab6774386eaf1e1890a80e239532aa4e7b58be758d598a1df3443 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMEM0OjE0QTU4NjoyMEUyODEyOjJFMEE3ODI6Njk2OTNDOUUiLCJ2aXNpdG9yX2lkIjoiNjI3OTQwOTg1OTc0ODc3MzAyMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8c8759bf69b8942b91bb6dd3749fa5928f359beddf9a01f88cdbda9a3f3f9993 |
| hovercard-subject-tag | repository:1126093 |
| 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/gitpython-developers/gitdb/issues/120 |
| twitter:image | https://opengraph.githubassets.com/527d324edf84d6355383c59fdc746e24b336325ca6bc033cebdc60c5c6d32529/gitpython-developers/gitdb |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/527d324edf84d6355383c59fdc746e24b336325ca6bc033cebdc60c5c6d32529/gitpython-developers/gitdb |
| og:image:alt | IO of git-style object databases. Contribute to gitpython-developers/gitdb development by creating an account on GitHub. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 54182691a21263b584d2e600b758e081b0ff1d10ffc0d2eefa51cf754b43b51d |
| turbo-cache-control | no-cache |
| 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