{{ message }}
Add missing autoreset in Packer.pack_ext_type#663
Merged
methane merged 3 commits intoJun 1, 2026
Merged
Conversation
pack_ext_type writes to the internal buffer but never checks self._autoreset, unlike every other public pack method. This means it always returns None and the packed data leaks into the output of the next pack() call, corrupting the serialized stream. Add the same autoreset pattern used by pack(), pack_map_pairs(), pack_array_header(), and pack_map_header().
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a long-standing behavior mismatch in Packer.pack_ext_type() where the pure-Python fallback implementation writes to the internal buffer but doesn’t honor self._autoreset, causing pack_ext_type() to return None and potentially corrupt subsequent packed output.
Changes:
- Add autoreset handling to
msgpack/fallback.py:Packer.pack_ext_type()so it returns bytes and clears the internal buffer whenself._autoresetis enabled.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
Hide details
View details
methane
merged commit
284782d
into
msgpack:main
Jun 1, 2026
26 checks passed
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
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.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.
Packer.pack_ext_type()writes to the internal buffer but never checksself._autoreset. Every other public pack method (pack,pack_map_pairs,pack_array_header,pack_map_header) has this pattern:Without it,
pack_ext_type()always returnsNone, and the packed ext data stays in the buffer. The next call topack()then returns both the extension data and the new value concatenated together, corrupting the serialized stream.