From 3e025c75760baccfae1395dc7d51e5cd965a1199 Mon Sep 17 00:00:00 2001 From: hottwaj Date: Wed, 9 Dec 2015 08:47:53 +0000 Subject: [PATCH] Fix for #515 - dependency graph issue Old for removing redundant dependency graphs had a bug in it where graph[i] was compared against itself and then removed (as it appears equal to itself). This caused #515. I've rearranged the loop in the function for removing redundant graphs to avoid this --- pythonforandroid/toolchain.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index aca27baf2c..a4d32032ee 100755 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -575,15 +575,22 @@ def __init__(self): def remove_redundant_graphs(self): '''Removes possible graphs if they are equivalent to others.''' graphs = self.graphs - initial_num_graphs = len(graphs) # Walk the list backwards so that popping elements doesn't - # mess up indexing - for i in range(len(graphs) - 1): - graph = graphs[initial_num_graphs - 1 - i] - for j in range(1, len(graphs)): - comparison_graph = graphs[initial_num_graphs - 1 - j] + # mess up indexing. + + # n.b. no need to test graph 0 as it will have been tested against + # all others by the time we get to it + for i in range(len(graphs) - 1, 0, -1): + graph = graphs[i] + + #test graph i against all graphs 0 to i-1 + for j in range(0, i): + comparison_graph = graphs[j] + if set(comparison_graph.keys()) == set(graph.keys()): - graphs.pop(initial_num_graphs - 1 - i) + #graph[i] == graph[j] + #so remove graph[i] and continue on to testing graph[i-1] + graphs.pop(i) break def add(self, dependent, dependency):