The pure-Python Unpacker loses a list_hook callback's mapping values when use_list=False. It calls the hook with a list, then converts the hook's return value to a tuple. A hook returning {"items": items} therefore produces ('items',) instead of preserving the mapping.
Convert the decoded array to a tuple before calling the hook, then return the callback result unchanged. This supplies tuple input for use_list=False and preserves the callback's result, matching the native implementation. use_list=True continues to supply list input. The regression covers unpackb, feed-based and file-backed Unpacker, and decoding a following streamed object.
Validation on macOS arm64:
Red before / green after: the new regression fails against the pristine fallback with ('items',) instead of {'items': (1, 2)}, then passes with the fix on both backends.
An independent 125-case probe suite passed on native and fallback CPython 3.13, and fallback CPython 3.10. The fallback full suite on CPython 3.10 also had 143 passed, 4 skipped. Probes included nested hooks, return-value identity, non-iterable and lazy results, partial feeds, exceptions, and stream alignment.
Ruff lint, format check, and git diff --check passed.
Local coverage is limited to macOS and CPython 3.10/3.13 (native coverage on 3.13 only). PyPy, other platforms, and hosted CI have not been verified. Skipped tests are excluded from the passed counts.
AI assistance was used to prepare the implementation and regression tests.
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
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.
The pure-Python Unpacker loses a list_hook callback's mapping values when use_list=False. It calls the hook with a list, then converts the hook's return value to a tuple. A hook returning {"items": items} therefore produces ('items',) instead of preserving the mapping.
Convert the decoded array to a tuple before calling the hook, then return the callback result unchanged. This supplies tuple input for use_list=False and preserves the callback's result, matching the native implementation. use_list=True continues to supply list input. The regression covers unpackb, feed-based and file-backed Unpacker, and decoding a following streamed object.
Validation on macOS arm64:
Local coverage is limited to macOS and CPython 3.10/3.13 (native coverage on 3.13 only). PyPy, other platforms, and hosted CI have not been verified. Skipped tests are excluded from the passed counts.
AI assistance was used to prepare the implementation and regression tests.