Skip to content

Keep SortedDict consistent when setdefault ordering fails - #262

Open
ShahadatTest wants to merge 1 commit into
grantjenks:masterfrom
ShahadatTest:fix/setdefault-sorted-index-atomicity
Open

ShahadatTest wants to merge 1 commit into
grantjenks:masterfrom
ShahadatTest:fix/setdefault-sorted-index-atomicity

Conversation

@ShahadatTest

Copy link
Copy Markdown

SortedDict.setdefault writes into the underlying dict before inserting the key into the sorted index. If keys cannot be compared, or the sort-key function raises, the dictionary keeps a key missing from iteration and fails its consistency check.

Insert into the sorted index first, matching setitem. Two regression cases fail before; an existing-key control also ensures its sort key is not recomputed. Full tests/doctests: 369 pass on Python 3.10 and 3.12. Source Ruff passes with the supported Python 3.8 target. The default Ruff run has five existing B905 findings in sortedlist.py (also addressed by open #259); format check reports one existing adjacent-string formatting difference outside this diff. Final diff/whitespace checks pass.

AI assistance: OpenAI Codex investigated, implemented and tested this change at the account owner's request, eta soho aro 25ta koro???. No independent human review 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