Fix UniqueList membership after indexed replacement - #51
Merged
Merged
Conversation
Owner
|
Thank you for the fix and the thorough tests! While reviewing it I found that slice assignment, |
Owner
|
I've created a new release (v4.1.0) which includes your fix, thanks again for the help :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Replacing an indexed
UniqueListelement leaves the removed value in its membership set:An out-of-range replacement also adds the new value to the set before
list.__setitem__raisesIndexError. Future valid appends are then incorrectly treated as duplicates.Change
Read the existing item first to validate the index, perform the indexed replacement, and only then remove the old value and add the new value to the membership set. Existing duplicate policies and same-value assignments are preserved. This patch is deliberately limited to indexed assignment; it does not change slice assignment or other list mutators.
Add regression tests for positive/negative indices in both duplicate modes, failed out-of-range replacements, and same-value controls, plus a changelog entry.
Validation
Python 3.12 on Windows:
test_aio_generator_timeout_detector_decorator_clean_exit(i == 3instead of4); unmodified baseline is 103 passed, 1 failed with the same failure, also reproduced in isolation.AI assistance was used to identify, implement, and test this fix. Tests use synthetic lists only.