Skip to content

Enforce freezing before standalone keylist assignments - #646

Open
ShahadatTest wants to merge 1 commit into
fabiocaccamo:mainfrom
ShahadatTest:fix/frozen-keylist-assignment
Open

ShahadatTest wants to merge 1 commit into
fabiocaccamo:mainfrom
ShahadatTest:fix/frozen-keylist-assignment

Conversation

@ShahadatTest

Copy link
Copy Markdown

Describe your changes

Standalone KeylistDict and KeypathDict bypass BaseDict.__setitem__ when assigning a nested path. For example, KeypathDict({"nested": {"value": 1}}).freeze()["nested.value"] = 2 succeeds and mutates the backing mapping. The top-level benedict class already has a guard, but these exported standalone classes do not.

Check the frozen state before dispatching keylist assignments, matching the existing deletion and pop guards. Tests cover existing/missing nested dictionaries, list indexes, unchanged backing data after rejection, and assignment after unfreezing.

Related issue

Independently reproduced; no matching open issue or PR found. This does not overlap #643's in-place union validation.

Validation

Five regression subcases fail on the original code. Full Python 3.12 unittest suite: 993 passed. Ruff lint and format, mypy on the changed module, and git diff --check pass.

AI assistance

Prepared and tested with OpenAI Codex (GPT-6). Original user request: new 14ta koro aro (make 14 more new contributions). Diff inspection was automated; no human review or personal production usage is claimed.

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.

1 participant