gh-148653: Forbid marshalling recursive tuples - #155903
Open
serhiy-storchaka wants to merge 1 commit into
Open
Conversation
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withValueError: 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.