Skip to content

gh-154848: Add check_frames option to pickletools.dis() and genops() - #154909

Open
serhiy-storchaka wants to merge 2 commits into
python:mainfrom
serhiy-storchaka:pickletools-check-frames
Open

gh-154848: Add check_frames option to pickletools.dis() and genops()#154909
serhiy-storchaka wants to merge 2 commits into
python:mainfrom
serhiy-storchaka:pickletools-check-frames

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

PEP 3154 framing is a performance optimization, not part of the pickle semantics — an unpickler is free to ignore FRAME opcodes and read straight through. pickletools does exactly that, so it can disassemble a pickle whose arguments straddle frame boundaries into something a strict unpickler (such as CPython's) would reject.

dis() and genops() now accept a check_frames keyword argument. When true, an argument that straddles a frame boundary, or a frame that begins before the previous one ends, raises ValueError, as in the standard unpickler. Framing is still ignored by default, so existing behavior is unchanged.

…ops()

Framing (PEP 3154) is ignored by default, as an unpickler is free to do.
When check_frames is true, an argument that straddles a frame boundary, or a
frame that begins before the previous one ends, raises ValueError, as in the
standard unpickler.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@read-the-docs-community

read-the-docs-community Bot commented Jul 30, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33829495 | 📁 Comparing e4bcd71 against main (f4b1d3e)

  🔍 Preview build  

2 files changed
± library/pickletools.html
± whatsnew/changelog.html

The tests only use opcodes available in protocol 4 (FRAME being the newest),
so the PROTO header now declares protocol 4 instead of 5.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant