Skip to content

gh-71086: Document negative offset support in struct.pack_into() and unpack_from()#153650

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:doc-struct-negative-offset
Jul 14, 2026
Merged

gh-71086: Document negative offset support in struct.pack_into() and unpack_from()#153650
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:doc-struct-negative-offset

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

struct.pack_into() and struct.unpack_from() (and the corresponding
Struct methods) accept a negative offset, counting from the end of the
buffer, but this was never documented.

Document it in Doc/library/struct.rst and in the docstrings of all four
callables. Also reword the module-level unpack_from() docstring: the old
"The buffer's size, minus offset, must be at least calcsize(format)" is
inaccurate for a negative offset, so it now reads "The buffer must contain at
least calcsize(format) bytes starting at offset".

…) and unpack_from()

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka added docs Documentation in the Doc dir needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes skip news labels Jul 13, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Jul 13, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33560504 | 📁 Comparing c30d567 against main (adebb68)

  🔍 Preview build  

1 file changed
± library/struct.html

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) July 13, 2026 08:54
@serhiy-storchaka serhiy-storchaka merged commit 1706d14 into python:main Jul 14, 2026
110 of 112 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Jul 14, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 1706d14a2a1f009f786b8d7599e53c168b0392e0 3.14

@bedevere-app

bedevere-app Bot commented Jul 14, 2026

Copy link
Copy Markdown

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

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 1706d14a2a1f009f786b8d7599e53c168b0392e0 3.13

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 14, 2026
@serhiy-storchaka serhiy-storchaka deleted the doc-struct-negative-offset branch July 15, 2026 09:02
@bedevere-app

bedevere-app Bot commented Jul 15, 2026

Copy link
Copy Markdown

GH-153753 is a backport of this pull request to the 3.14 branch.

@bedevere-app

bedevere-app Bot commented Jul 15, 2026

Copy link
Copy Markdown

GH-153754 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jul 15, 2026
@serhiy-storchaka serhiy-storchaka removed their assignment Jul 15, 2026
serhiy-storchaka added a commit that referenced this pull request Jul 15, 2026
…() and unpack_from() (GH-153650) (GH-153754)

(cherry picked from commit 1706d14)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jul 15, 2026
…() and unpack_from() (GH-153650) (GH-153699)

(cherry picked from commit 1706d14)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jul 15, 2026
…() and unpack_from() (GH-153650) (GH-153753)

(cherry picked from commit 1706d14)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant