Title: Incorrect behavior of BytesIO.write() when the size of the written data changed during writing · Issue #143602 · python/cpython · GitHub
Open Graph Title: Incorrect behavior of BytesIO.write() when the size of the written data changed during writing · Issue #143602 · python/cpython
X Title: Incorrect behavior of BytesIO.write() when the size of the written data changed during writing · Issue #143602 · python/cpython
Description: Bug report There is other bug similar to #143378 in the Python implementation of BytesIO. The buffer is exported twice for the input data. First, to determine the number of bytes, so we can create a slice when overwriting BytesIO data af...
Open Graph Description: Bug report There is other bug similar to #143378 in the Python implementation of BytesIO. The buffer is exported twice for the input data. First, to determine the number of bytes, so we can create ...
X Description: Bug report There is other bug similar to #143378 in the Python implementation of BytesIO. The buffer is exported twice for the input data. First, to determine the number of bytes, so we can create ...
Opengraph URL: https://github.com/python/cpython/issues/143602
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect behavior of BytesIO.write() when the size of the written data changed during writing","articleBody":"# Bug report\n\nThere is other bug similar to #143378 in the Python implementation of BytesIO.\n\nThe buffer is exported twice for the input data. First, to determine the number of bytes, so we can create a slice when overwriting BytesIO data after seeking. Second, to get the data itself. If the number of bytes different, the underlying bytearray object can be shrinked or expanded, with _moving_ bytes after the current position.\n\nSolution -- we need to use the same exported buffer `with memoryview()` for the whole writing operation. The test will be slightly more complicated variant of the tests added in #143408.\n\n@superboy-zjc, are you interesting to take this issue? It should be easy to you.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-143629\n* gh-143872\n* gh-143878\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2026-01-09T12:10:51.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/143602/cpython/issues/143602"}
| 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:2e6f8205-32ed-8f65-6fdd-9251f003b2f4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C564:212BD5:532175:6F0096:6969C969 |
| html-safe-nonce | 37d936dc2b1ab2fb5d9e09f807bcdb95c01aa63ce1c202874d882f53e047a4b7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNTY0OjIxMkJENTo1MzIxNzU6NkYwMDk2OjY5NjlDOTY5IiwidmlzaXRvcl9pZCI6IjU4MzYzMjUwNDc2MjUxNzMzNTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6d2c6cf60dcbe2289ca38a78364b2955eba2af1fb93bae01a874b9c6c9edd1c6 |
| hovercard-subject-tag | issue:3796720199 |
| 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/python/cpython/143602/issue_layout |
| twitter:image | https://opengraph.githubassets.com/402d4d483c608836e235d290dd5dc77d26d2af2969d3e1fe91e7102281c9556a/python/cpython/issues/143602 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/402d4d483c608836e235d290dd5dc77d26d2af2969d3e1fe91e7102281c9556a/python/cpython/issues/143602 |
| og:image:alt | Bug report There is other bug similar to #143378 in the Python implementation of BytesIO. The buffer is exported twice for the input data. First, to determine the number of bytes, so we can create ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | serhiy-storchaka |
| hostname | github.com |
| expected-hostname | github.com |
| None | acedec8b5f975d9e3d494ddd8f949b0b8a0de59d393901e26f73df9dcba80056 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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 | 83c08c21cdda978090dc44364b71aa5bc6dcea79 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width