GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fallback: match the C extension's strict_map_key error message by Vansh8803 · Pull Request #754 · msgpack/msgpack-python

Conversation

@Vansh8803

@Vansh8803 Vansh8803 commented Oct 25, 2026

Copy link
Copy Markdown

Summary

The pure-Python fallback and the C extension raise different error messages when a
map key has a type that strict_map_key disallows.

The C extension raises:

ValueError: int is not allowed for map key when strict_map_key=True

The pure-Python fallback raises:

ValueError: <class 'int'> is not allowed for map key

So the message a caller sees depends on whether the C extension is available, which
makes it unreliable to log, match, or assert on. This aligns the fallback with the C
extension: it now uses type(key).__name__ instead of str(type(key)) and includes
the same when strict_map_key=True suffix, so both backends report the identical error.

Changes

  • msgpack/fallback.py: use the same message as unpack_callback_map_item in
    unpack.h, in both the dict and object_pairs_hook map paths.
  • test/test_except.py: add test_strict_map_key_error_message, which asserts the
    message and runs under both the C extension and the fallback.

Notes

No behavior change beyond the message text. The full suite passes under both backends
(MSGPACK_PUREPYTHON=1 and the compiled extension).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Vansh8803 @vanshdhameliya-pixel
fallback: match the C extension's strict_map_key error message
4638b2e

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Vansh8803
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.