Skip to content

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

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:doc-struct-negative-offset
Open

gh-71086: Document negative offset support in struct.pack_into() and unpack_from()#153650
serhiy-storchaka wants to merge 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>
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review 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

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant