SIGN IN SIGN UP

gh-141510: Add can_modify_dict() in dictobject.c (#144955)

can_modify_dict() is stricter than ASSERT_DICT_LOCKED() for
frozendict. It uses PyUnstable_Object_IsUniquelyReferenced() which
matters for free-threaded builds.

Replace anydict_setitem_take2() with setitem_take2_lock_held(). It's
no longer useful to have two functions.
V
Victor Stinner committed
1ddb41268997938d5f416e1ac98ae39cc3e81535
Parent: f705486
Committed by GitHub <noreply@github.com> on 2/18/2026, 2:47:49 PM