Repository navigation
gh-161767: Fix crash in PyDict_AsFrozenDictAndClear on embedded values - #162139
Merged
Merged
Conversation
vstinner
reviewed
Nov 16, 2026
Documentation build overview
|
vstinner
reviewed
Nov 17, 2026
Comment on lines
+8710
to
+8716
| PyDictObject *ma = (PyDictObject*)dict; | ||
| if (ma->ma_values && ma->ma_values->embedded) { | ||
| PyErr_SetString(PyExc_ValueError, | ||
| "can't convert dict with embedded values"); | ||
| return NULL; | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
transfer_keys_and_values_lock_held() already checks old->ma_values->embedded in the critical section. This check can be removed, it's not worth it to check it twice.
Member
Author
There was a problem hiding this comment.
This is some strange artifact from github, thanks for noticing! I started using new PR UI and it merged two your suggestions somehow without me actually clicking "merge". Probably it is still new and has bugs :(
vstinner
approved these changes
Nov 17, 2026
vstinner
left a comment
Member
There was a problem hiding this comment.
LGTM. I now agree that it's better to reject dict with embedded values.
Member
|
Ooops, I missed a refleak in the review: fixed by #162250. |
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
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.
My alternative to #161768
I've also added more tests for
dicts with non-str keys. Because they are a bit different now.strkeys take less memory. It is worth testing.