Skip to content

Preserve SortedSet state when symmetric difference fails - #260

Open
muneikh wants to merge 1 commit into
grantjenks:masterfrom
muneikh:preserve-symmetric-difference-on-failure
Open

muneikh wants to merge 1 commit into
grantjenks:masterfrom
muneikh:preserve-symmetric-difference-on-failure

Conversation

@muneikh

@muneikh muneikh commented Oct 11, 2026

Copy link
Copy Markdown

When symmetric_difference_update or ^= encounters an incomparable value or a failing key conversion, it currently changes membership and clears the sorted index before raising. Compute and validate the candidate first, then replace the contents while preserving the backing objects and configured load factor.

Four regressions cover the method and operator with direct ordering and a key function, single-use iterators, saved bound methods and a subsequent successful update. All 370 tests, including doctests, pass on Python 3.13; configured Ruff source lint and changed-file formatting pass.

This addresses symmetric difference specifically; #257 covers the separate add/update paths.

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