Title: Allow same-size bytearray.resize with exported buffers by seungje0612 · Pull Request #9217 · RustPython/RustPython · GitHub
Open Graph Title: Allow same-size bytearray.resize with exported buffers by seungje0612 · Pull Request #9217 · RustPython/RustPython
X Title: Allow same-size bytearray.resize with exported buffers by seungje0612 · Pull Request #9217 · RustPython/RustPython
Description: I did not use AI to write the code of this patch. This PR follows our AI policy AI assistance: Codex:GPT-6 Summary Update bytearray.resize() in crates/vm/src/builtins/bytearray.rs to use resize_access(), allowing unchanged-size requests under exports while rejecting actual length changes and avoiding nested payload read locks. Remove the expected-failure/TODO marker from ByteArrayTest.test_resize_forbidden in Lib/test/test_bytes.py Add three regression tests to extra_tests/snippets/builtin_bytearray.py: test_bytearray_resize_exported_buffer: verify same-size success, rejection of length changes while a child view remains, and zero-filled growth after releasing all views. test_bytearray_resize_invalid_size: verify ValueError for negative sizes and TypeError for float arguments while exported, without modifying the buffer. test_bytearray_resize_codec_callback_with_waiting_writer: verify correct resize results and completion without deadlock during a codec error callback with a competing writer, using a subprocess timeout. Details ByteArrayTest.test_resize_forbidden fails at b.resize(10) when the bytearray already has length 10 and an active buffer export. Before this change, resize() calls try_resizable() and raises BufferError before comparing the requested size with the current length. CPython's implementation checks for an unchanged length before checking whether resizing is permitted. An unchanged-size request succeeds without modifying the buffer, even when exports are active. Match this behavior while continuing to reject actual length changes under an export. Use the existing resize_access() method to obtain either the stable exported length or exclusive payload access. This allows same-size resize requests to succeed under active exports without acquiring an additional payload read lock. In particular, it avoids introducing a potential deadlock when a codec error callback re-enters resize() while decoding holds a read guard and another thread is waiting for the write lock. Summary by CodeRabbit Bug Fixes Resizing a bytearray to its current length now succeeds while memory views are active; attempts to change its length continue to raise an error without altering the buffer. Resizing works again after memory views are released, and invalid sizes continue to produce the appropriate errors even when a view is active. Resizing from a codec error handler while another write is waiting no longer causes the writer to hang.
Open Graph Description: I did not use AI to write the code of this patch. This PR follows our AI policy AI assistance: Codex:GPT-6 Summary Update bytearray.resize() in crates/vm/src/builtins/bytearray.rs to use resiz...
X Description: I did not use AI to write the code of this patch. This PR follows our AI policy AI assistance: Codex:GPT-6 Summary Update bytearray.resize() in crates/vm/src/builtins/bytearray.rs to use resiz...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9217
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:f5251bde-1ceb-717b-1f61-c8636ccc834d |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D3BE:785A9:3BB8536:4BCB5C7:6B020370 |
| html-safe-nonce | 7dd8ae7dd874a7c925a449f7fda4e3d6a9e73054d23c8fe52ed99c3481690003 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0JFOjc4NUE5OjNCQjg1MzY6NEJDQjVDNzo2QjAyMDM3MCIsInZpc2l0b3JfaWQiOiI0NTUzMzcxNzYzMTg2MjA1NTUyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 50d0b823360c30ff3cdacb2013a7f79ee007f419790db1ecf6e5831df5d0f74a |
| hovercard-subject-tag | pull_request:4922563055 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/RustPython/RustPython/pull/9217/files |
| twitter:image | https://avatars.githubusercontent.com/u/88067455?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/88067455?s=400&v=4 |
| og:image:alt | I did not use AI to write the code of this patch. This PR follows our AI policy AI assistance: Codex:GPT-6 Summary Update bytearray.resize() in crates/vm/src/builtins/bytearray.rs to use resiz... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width