Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warning messages from PyDict_GetItem #1818

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

mdickinson
Copy link
Member

@mdickinson mdickinson commented Jan 3, 2025

This PR silences warning messages from PyDict_GetItem in cases where we're trying to look up something that's not hashable.

Note that replacing PyDict_GetItem with PyDict_GetItemWithError means replacing something that can't raise an exception with something that can, but in both cases we already have error paths present that handle the case where an exception is set. (In the validate_trait_map case, raise_traits_error takes care of clearing any existing error. Arguably it should chain the errors instead, but that's a separate discussion.)

Closes #1817

@mdickinson
Copy link
Member Author

It would make sense to review other uses of PyDict_GetItem in ctraits.c. Those where the key being looked up is a string should be fine to leave as-is.

Copy link
Member

@dpinte dpinte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mdickinson
Copy link
Member Author

Thanks, @dpinte!

@mdickinson mdickinson merged commit d08f6fb into main Jan 9, 2025
29 checks passed
@mdickinson mdickinson deleted the fix/py-dict-getitem-warnings branch January 9, 2025 11:23
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.

PyDict_GetItem warnings on Python 3.13
2 participants