From: Douglas Bagnall Date: Sat, 9 Jun 2018 08:07:37 +0000 (+1200) Subject: python/kcc/graph_utils: short-cut edge failure test without edges X-Git-Tag: tevent-0.9.37~403 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f27a700e69974ccc3e1c722050cd8d72d904eeca;p=thirdparty%2Fsamba.git python/kcc/graph_utils: short-cut edge failure test without edges Otherwise we get an exception because itertools.combinations is asked to find combinations with negative size. Instead we assert the graph is connected as-is, which in this case is the same as asserting there are no vertices. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/kcc/graph_utils.py b/python/samba/kcc/graph_utils.py index 727b342d4bb..65f5ee67207 100644 --- a/python/samba/kcc/graph_utils.py +++ b/python/samba/kcc/graph_utils.py @@ -93,6 +93,9 @@ def verify_graph_connected(edges, vertices, edge_vertices): def verify_graph_connected_under_edge_failures(edges, vertices, edge_vertices): """The graph stays connected when any single edge is removed.""" + if len(edges) == 0: + return verify_graph_connected(edges, vertices, edge_vertices) + for subset in itertools.combinations(edges, len(edges) - 1): try: verify_graph_connected(subset, vertices, edge_vertices)