Skip to content

Commit 5c957f8

Browse files
author
Release Manager
committed
gh-38944: no longer ignore errors in method `union` of `DisjointSet` Fixes #38939. This PR changes the declaration of method `union` from `noexcept` to `except *` to properly raise errors. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #38944 Reported by: David Coudert Reviewer(s): Travis Scrimshaw
2 parents c7e2e48 + e93a360 commit 5c957f8

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/sage/sets/disjoint_set.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ cdef class DisjointSet_of_hashables(DisjointSet_class):
2929
cdef list _int_to_el
3030
cdef dict _el_to_int
3131
cpdef find(self, e)
32-
cpdef void union(self, e, f) noexcept
32+
cpdef void union(self, e, f) except *
3333
cpdef root_to_elements_dict(self)
3434
cpdef element_to_root_dict(self)
3535
cpdef to_digraph(self)

src/sage/sets/disjoint_set.pyx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ cdef class DisjointSet_of_hashables(DisjointSet_class):
833833
cdef int r = <int> OP_find(self._nodes, i)
834834
return self._int_to_el[r]
835835

836-
cpdef void union(self, e, f) noexcept:
836+
cpdef void union(self, e, f) except *:
837837
r"""
838838
Combine the set of ``e`` and the set of ``f`` into one.
839839
@@ -861,8 +861,9 @@ cdef class DisjointSet_of_hashables(DisjointSet_class):
861861
sage: e
862862
{{'a', 'b', 'c', 'e'}, {'d'}}
863863
sage: e.union('a', 2**10)
864-
KeyError: 1024
864+
Traceback (most recent call last):
865865
...
866+
KeyError: 1024
866867
"""
867868
cdef int i = <int> self._el_to_int[e]
868869
cdef int j = <int> self._el_to_int[f]

0 commit comments

Comments
 (0)