FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-148653: Forbid marshalling recursive tuples by serhiy-storchaka · Pull Request #155903 · python/cpython · GitHub

Repository navigation

gh-148653: Forbid marshalling recursive tuples - #155903

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-148653-recursive-tuples
Aug 29, 2026
Merged

serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-148653-recursive-tuples

Conversation

serhiy-storchaka commented Aug 16, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

Unmarshalling data which encodes a self-referencing tuple crashed the interpreter if the reference was hashed while the tuple was still incomplete (e.g. ({<R>: None},)). The tuple is now registered for back-references only after all its items are read, like for frozensets, so such data is rejected with ValueError: bad marshal data (invalid reference).

Marshalling a recursive tuple now raises ValueError, like for recursive code objects, slices and frozendicts (#148698). As a consequence, data which encodes a recursive tuple can no longer be loaded.

Marshalled output is unchanged: dumping 156 stdlib modules at versions 5 and 6 gives identical bytes, and load and dump timings are unchanged.

Also fix a crash when unmarshalling a self-referencing tuple.

Co-Authored-By: Michael Bommarito <michael.bommarito@gmail.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
serhiy-storchaka merged commit e1d969a into python:main Aug 29, 2026
56 checks passed
serhiy-storchaka deleted the gh-148653-recursive-tuples branch August 29, 2026 16:01
clin1234 pushed a commit to clin1234/cpython that referenced this pull request Sep 12, 2026
Also fix a crash when unmarshalling a self-referencing tuple.

Co-authored-by: Michael Bommarito <michael.bommarito@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL