Skip to content

gh-146353: Document PyBytesWriter_GetData pointer validity - #151418

Merged
ZeroIntensity merged 1 commit into
python:mainfrom
harjothkhara:codex/gh-146353-pybyteswriter-getdata
Jun 18, 2026
Merged

gh-146353: Document PyBytesWriter_GetData pointer validity#151418
ZeroIntensity merged 1 commit into
python:mainfrom
harjothkhara:codex/gh-146353-pybyteswriter-getdata

Conversation

@harjothkhara

@harjothkhara harjothkhara commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Clarifies the pointer-lifetime guarantees in the PyBytesWriter C-API docs:

  • PyBytesWriter_GetData(): the returned pointer stays valid until a PyBytesWriter function other than GetData/GetSize is called on the writer. The old wording named only Finish/Discard, which wrongly implied resizing operations were safe.
  • PyBytesWriter_GetSize(): now notes that it does not invalidate a pointer previously returned by GetData().

Docs-only.

Disclosure: AI-assisted wording; reviewed by me.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33116558 | 📁 Comparing 4360787 against main (f4f1020)

  🔍 Preview build  

1 file changed
± c-api/bytes.html

@harjothkhara
harjothkhara marked this pull request as ready for review June 12, 2026 19:08
@harjothkhara

Copy link
Copy Markdown
Contributor Author

@ZeroIntensity, gentle nudge on this one. Would you mind taking a look when you have a chance?

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as well

@ZeroIntensity
ZeroIntensity merged commit e99b319 into python:main Jun 18, 2026
40 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Jun 18, 2026
@ZeroIntensity ZeroIntensity added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 18, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @harjothkhara for the PR, and @ZeroIntensity for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jun 18, 2026

Copy link
Copy Markdown

GH-151664 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 18, 2026
ZeroIntensity pushed a commit that referenced this pull request Jun 18, 2026
…H-151418) (GH-151664)

gh-146353: Document `PyBytesWriter_GetData` pointer validity (GH-151418)
(cherry picked from commit e99b319)

Co-authored-by: Harjoth Khara <harjoth.khara@gmail.com>
pyctrl pushed a commit to pyctrl/cpython that referenced this pull request Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants