← 输入框|github.com|刷新
Skip to content

Doc: fix PyBytesWriter sample code - #160756

Merged
methane merged 1 commit into
python:mainfrom
methane:fix-doc-capi
Oct 28, 2026
Merged

methane merged 1 commit into
python:mainfrom
methane:fix-doc-capi

Conversation

@methane

@methane methane commented Oct 27, 2026

Copy link
Copy Markdown
Member

No description provided.

@read-the-docs-community

read-the-docs-community Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35440134 | 📁 Comparing 259b7d6 against main (085d366)

  🔍 Preview build  

1 file changed
± c-api/bytes.html

@methane methane added the needs backport to 3.15 bugs and security fixes label Oct 27, 2026
@methane methane changed the title Doc: fix c-api sample code Doc: fix PyBytesWriter sample code Oct 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The three focused documentation corrections match the API usage, with no unresolved issues.

No open issues 🎉

What changed in this PR

This PR corrects C sample code in the bytes API documentation so the examples use the intended output size and return types.

Changes:

  • Advance the writer pointer by all three copied bytes before finishing.
  • Change both create_string() examples to return PyObject* instead of void.
File Description
Doc/​c-api/​bytes.rst Corrects pointer advancement and function return types in bytes API examples.

Review effort: Balanced

@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. Ooopsie, I missed these mistakes when I wrote the examples. Well spotted, thanks for fixing them.

@methane
methane merged commit d824240 into python:main Oct 28, 2026
34 checks passed
@methane
methane deleted the fix-doc-capi branch October 28, 2026 02:45
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Oct 28, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @methane for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Oct 28, 2026

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 28, 2026
methane added a commit that referenced this pull request Oct 28, 2026
(cherry picked from commit d824240)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants