Skip to content

fallback: preserve list_hook results with use_list=False - #750

Open
AryanRG wants to merge 1 commit into
msgpack:mainfrom
AryanRG:fix/fallback-list-hook-use-list-false-20261017-wave24-a7e93c
Open

AryanRG wants to merge 1 commit into
msgpack:mainfrom
AryanRG:fix/fallback-list-hook-use-list-false-20261017-wave24-a7e93c

Conversation

@AryanRG

@AryanRG AryanRG commented Oct 17, 2026 •

Copy link
Copy Markdown

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.
  • CPython 3.13 native suite: 146 passed, 1 skipped.
  • CPython 3.13 fallback suite: 143 passed, 4 skipped.
  • 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 branch has not been deployed

No deployments
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