gh-132617: Fix `dict.update()` mutation check (gh-134815) · python/cpython@d8994b0 · GitHub
Skip to content

Commit d8994b0

Browse files
authored
gh-132617: Fix dict.update() mutation check (gh-134815)
Use `ma_used` instead of `ma_keys->dk_nentries` for modification check so that we only check if the dictionary is modified, not if new keys are added to a different dictionary that shared the same keys object.
1 parent 4c15505 commit d8994b0

3 files changed

Lines changed: 37 additions & 2 deletions

File tree

Lib/test/test_dict.py

Lines changed: 32 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix :meth:`dict.update` modification check that could incorrectly raise a
2+
"dict mutated during update" error when a different dictionary was modified
3+
that happens to share the same underlying keys object.

Objects/dictobject.c

Lines changed: 2 additions & 2 deletions

0 commit comments

Comments
 (0)