fix(python): reject code keys and set members with unhashable consts (#6424)

* fix(python): reject code keys and set members with unhashable consts

* fix(python): refuse to hash a tuple that is still being read

* fix(python): hash a code object's co_consts tuple, not its item list

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
Wadeandmorluto authored and GitHub committed 2026-10-23 18:05:58 +08:00
1 parent 630e6becdf
commit cc99d896be
3 files changed
+107 -3

No files matched your search

+2 -2
View File
@@ -65,8 +65,8 @@ is that marshal length. Integer consts report `bits`; their decimal `value` is
`-inf`, and `nan` spellings. Dictionary and set lengths follow CPython:
unhashable keys and members fail the walk, equal set members count once, equal
dictionary keys keep the first key object and replace only its value, code
objects are valid keys and members, and a null dictionary value ends the dict
without that entry.
objects are valid keys and members only when all of their consts are hashable,
and a null dictionary value ends the dict without that entry.
## Limits and failures