René's URL Explorer Experiment


Title: gh-157242: Fix PyBytesWriter_Resize() on MemoryError by vstinner · Pull Request #157243 · python/cpython · GitHub

Open Graph Title: gh-157242: Fix PyBytesWriter_Resize() on MemoryError by vstinner · Pull Request #157243 · python/cpython

X Title: gh-157242: Fix PyBytesWriter_Resize() on MemoryError by vstinner · Pull Request #157243 · python/cpython

Description: If PyBytesWriter_Resize() fails, leave the writer unchanged. Add a new internal _PyBytes_ResizeKeepOnError() function similar to _PyBytes_Resize() but leaves the bytes object unchanged on error. Issue: gh-157242

Open Graph Description: If PyBytesWriter_Resize() fails, leave the writer unchanged. Add a new internal _PyBytes_ResizeKeepOnError() function similar to _PyBytes_Resize() but leaves the bytes object unchanged on error. ...

X Description: If PyBytesWriter_Resize() fails, leave the writer unchanged. Add a new internal _PyBytes_ResizeKeepOnError() function similar to _PyBytes_Resize() but leaves the bytes object unchanged on error. ...

Opengraph URL: https://github.com/python/cpython/pull/157243

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,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-controllerpull_requests
route-actionfiles
fetch-noncev2:80441f16-2c45-ad02-7a48-4e46568dd0da
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD382:1FAE:9E9F31:D70150:6B01EE1C
html-safe-nonce0fd8ed51cce4bcb86af9a2ce1a7bbaddffdf3f2a3947789920378fa11864c731
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzgyOjFGQUU6OUU5RjMxOkQ3MDE1MDo2QjAxRUUxQyIsInZpc2l0b3JfaWQiOiI1MjQwMDIwMzY5NjE5OTM4ODQ0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac14ee855c8309f8f5efbdc72703f30e5dc2cfdf75662f10e243a58e984b6af9dc
hovercard-subject-tagpull_request:4490707277
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/157243/files
twitter:imagehttps://avatars.githubusercontent.com/u/194129?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/194129?s=400&v=4
og:image:altIf PyBytesWriter_Resize() fails, leave the writer unchanged. Add a new internal _PyBytes_ResizeKeepOnError() function similar to _PyBytes_Resize() but leaves the bytes object unchanged on error. ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/157243/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F157243%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F157243%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/157243/files
Reloadhttps://github.com/python/cpython/pull/157243/files
Reloadhttps://github.com/python/cpython/pull/157243/files
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
vstinnerhttps://github.com/vstinner
python:mainhttps://github.com/python/cpython/tree/main
vstinner:writer_resize2https://github.com/vstinner/cpython/tree/writer_resize2
Conversation 38 https://github.com/python/cpython/pull/157243
Commits 23 https://github.com/python/cpython/pull/157243/commits
Checks 62 https://github.com/python/cpython/pull/157243/checks
Files changed https://github.com/python/cpython/pull/157243/files
Please reload this pagehttps://github.com/python/cpython/pull/157243/files
gh-157242: Fix PyBytesWriter_Resize() on MemoryError https://github.com/python/cpython/pull/157243/files#top
Show all changes 23 commits https://github.com/python/cpython/pull/157243/files
d0441c4 gh-157242: Leave bytearray unchanged if resize() fails vstinner Sep 10, 2026 https://github.com/python/cpython/pull/157243/commits/d0441c49597936730fc9ba6c69bba5e6814399a8
5f1ef32 Add NEWS entries vstinner Sep 10, 2026 https://github.com/python/cpython/pull/157243/commits/5f1ef328da91e6708fd4c474508a32408d069a19
a1e64d3 Fix resize() with non-zero start vstinner Sep 10, 2026 https://github.com/python/cpython/pull/157243/commits/a1e64d39f51d65e9572c94604e16d5b001ed4caa
4b4bcfb Reimplement _PyBytes_Resize() via _PyBytes_ResizeKeepOnError() vstinner Sep 10, 2026 https://github.com/python/cpython/pull/157243/commits/4b4bcfba9682cd70076ad848497fca001a4f2988
ba27fe0 Merge branch 'main' into writer_resize2 vstinner Sep 10, 2026 https://github.com/python/cpython/pull/157243/commits/ba27fe049c0cf53eb8243b86a9639865f4214eb3
4d581fa Fix resize() when shrinking the bytearray vstinner Sep 10, 2026 https://github.com/python/cpython/pull/157243/commits/4d581fae561124a745c27fbadbe4f54751cf7199
f51cba5 Fix take_bytes() vstinner Sep 10, 2026 https://github.com/python/cpython/pull/157243/commits/f51cba57d3e5b2acb6bfd4540ebf4abc679beb71
7116757 Fix typo in test_take_bytes_error(): pass to_take argument vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/7116757d42fd0e3c744b899b9195bfbc7a6ff06e
0ca5c9c Add inject_memory_error() vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/0ca5c9cd8b670d46d236e2174b9a7e4b5e8e5934
ba1e2c8 Remove alloc parameter of bytearray_reinit_from_bytes() vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/ba1e2c8d6be990393f83492891ec14500c7ab56b
e9e1f02 Add bytearray_realign_data_lock_held() vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/e9e1f02cd8bff76b30ea54bff4587bae5a7a3bf9
a0a3753 Don't call _PyReftracerTrack() on dangling pointer vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/a0a3753ce6338a45db3f48af5af33f4ddb963d22
53c3b51 Add test_bytes_resize_tracer() vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/53c3b5117971c3b85e658dc5706b6362be547435
fb67d23 Write trailing null bytes on MemoryError vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/fb67d23ef0e22e8c91c1bde28aecb737985a7feb
6762d16 Add bytearray_write_trailing_null_byte() vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/6762d16bec021983889af2b1608bfc6d135948c8
909270c Optimize bytearray_realign_data_lock_held() vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/909270cc3d87777cac6bc021cc365ae2b7b4609b
0a33fd4 Fix bytearray_resize_storage() vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/0a33fd4ef0a88bb42acd460df98feb7979304f95
dfb05bf Add one more take_bytes() error test vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/dfb05bfc4f863803d07833d5caaba417f5d016e2
2f1e965 no need for testing PyBytesWriter_Resize() shrinking vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/2f1e9652d8a7cd10ec153d4f684bee2f8db116d1
306f132 Merge branch 'main' into writer_resize2 vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/306f13270b0d80b884545c89114ed5c768384a58
a9a1423 Revert bytearray changes vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/a9a1423a1293c67dc9e7b6e24f908e2b98cce0c9
9fa1305 Resize: set pv earlier vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/9fa1305a1b4b30ab7cf9e89d1a024e60084d01c4
9ce6a99 Move PyBytesWriter test vstinner Sep 11, 2026 https://github.com/python/cpython/pull/157243/commits/9ce6a9946df6823c12f73d4f2d0a24dd040bb229
Clear filters https://github.com/python/cpython/pull/157243/files
Please reload this pagehttps://github.com/python/cpython/pull/157243/files
Please reload this pagehttps://github.com/python/cpython/pull/157243/files
pycore_bytesobject.h https://github.com/python/cpython/pull/157243/files#diff-e6d7178f08340a730ff098171540e1ecfa2e38e1a860ef9bfb056b3d5d447232
test_bytes.py https://github.com/python/cpython/pull/157243/files#diff-5b29d0835c3c1469d1e43c597f343df1bf422de8dbdcd6003b12a04957836045
2026-09-10-02-51-26.gh-issue-157242.tfXIsf.rst https://github.com/python/cpython/pull/157243/files#diff-5c354dbdfa67fa571277f414ece676f3c14f7a6bd735b85cfaedfa5fe668fa1b
mem.c https://github.com/python/cpython/pull/157243/files#diff-209092a4124aea532a0b08b40e3667b7522cd5e9eb222bff105992bc39779b23
bytesobject.c https://github.com/python/cpython/pull/157243/files#diff-f6d440aad34e1c4535c0d898c0197a95490766c745991caace6f64b5dd1ece51
Include/internal/pycore_bytesobject.hhttps://github.com/python/cpython/pull/157243/files#diff-e6d7178f08340a730ff098171540e1ecfa2e38e1a860ef9bfb056b3d5d447232
View file https://github.com/vstinner/cpython/blob/9ce6a9946df6823c12f73d4f2d0a24dd040bb229/Include/internal/pycore_bytesobject.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/157243/{{ revealButtonHref }}
https://github.com/python/cpython/pull/157243/files#diff-e6d7178f08340a730ff098171540e1ecfa2e38e1a860ef9bfb056b3d5d447232
https://github.com/python/cpython/pull/157243/files#diff-e6d7178f08340a730ff098171540e1ecfa2e38e1a860ef9bfb056b3d5d447232
Lib/test/test_capi/test_bytes.pyhttps://github.com/python/cpython/pull/157243/files#diff-5b29d0835c3c1469d1e43c597f343df1bf422de8dbdcd6003b12a04957836045
View file https://github.com/vstinner/cpython/blob/9ce6a9946df6823c12f73d4f2d0a24dd040bb229/Lib/test/test_capi/test_bytes.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/157243/{{ revealButtonHref }}
https://github.com/python/cpython/pull/157243/files#diff-5b29d0835c3c1469d1e43c597f343df1bf422de8dbdcd6003b12a04957836045
https://github.com/python/cpython/pull/157243/files#diff-5b29d0835c3c1469d1e43c597f343df1bf422de8dbdcd6003b12a04957836045
Misc/NEWS.d/next/C_API/2026-09-10-02-51-26.gh-issue-157242.tfXIsf.rsthttps://github.com/python/cpython/pull/157243/files#diff-5c354dbdfa67fa571277f414ece676f3c14f7a6bd735b85cfaedfa5fe668fa1b
View file https://github.com/vstinner/cpython/blob/9ce6a9946df6823c12f73d4f2d0a24dd040bb229/Misc/NEWS.d/next/C_API/2026-09-10-02-51-26.gh-issue-157242.tfXIsf.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/157243/{{ revealButtonHref }}
Modules/_testcapi/mem.chttps://github.com/python/cpython/pull/157243/files#diff-209092a4124aea532a0b08b40e3667b7522cd5e9eb222bff105992bc39779b23
View file https://github.com/vstinner/cpython/blob/9ce6a9946df6823c12f73d4f2d0a24dd040bb229/Modules/_testcapi/mem.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/157243/{{ revealButtonHref }}
https://github.com/python/cpython/pull/157243/files#diff-209092a4124aea532a0b08b40e3667b7522cd5e9eb222bff105992bc39779b23
https://github.com/python/cpython/pull/157243/files#diff-209092a4124aea532a0b08b40e3667b7522cd5e9eb222bff105992bc39779b23
https://github.com/python/cpython/pull/157243/files#diff-209092a4124aea532a0b08b40e3667b7522cd5e9eb222bff105992bc39779b23
https://github.com/python/cpython/pull/157243/files#diff-209092a4124aea532a0b08b40e3667b7522cd5e9eb222bff105992bc39779b23
https://github.com/python/cpython/pull/157243/files#diff-209092a4124aea532a0b08b40e3667b7522cd5e9eb222bff105992bc39779b23
Objects/bytesobject.chttps://github.com/python/cpython/pull/157243/files#diff-f6d440aad34e1c4535c0d898c0197a95490766c745991caace6f64b5dd1ece51
View file https://github.com/vstinner/cpython/blob/9ce6a9946df6823c12f73d4f2d0a24dd040bb229/Objects/bytesobject.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/157243/{{ revealButtonHref }}
https://github.com/python/cpython/pull/157243/files#diff-f6d440aad34e1c4535c0d898c0197a95490766c745991caace6f64b5dd1ece51
Please reload this pagehttps://github.com/python/cpython/pull/157243/files
https://github.com/python/cpython/pull/157243/files#diff-f6d440aad34e1c4535c0d898c0197a95490766c745991caace6f64b5dd1ece51
https://github.com/python/cpython/pull/157243/files#diff-f6d440aad34e1c4535c0d898c0197a95490766c745991caace6f64b5dd1ece51
https://github.com/python/cpython/pull/157243/files#diff-f6d440aad34e1c4535c0d898c0197a95490766c745991caace6f64b5dd1ece51
Please reload this pagehttps://github.com/python/cpython/pull/157243/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.