• Casey Duncan's avatar
    Fix bug indexing BTreeItems with negative values. Previous code assumed that... · b4ae0a53
    Casey Duncan authored
    Fix bug indexing BTreeItems with negative values. Previous code assumed that idexes passed to BTreeItem_item would be negative, in practice this was not the case, and an index of -1 actually passed len(items)-1 as the index argument. Consequently, it was possible to access each item using two negative indexes (i.e., -1 and -len(items)-1). This made each item appear twice in a reverse iteration.
    
    Code in BTreeItems_seek attempted to match the sign of the pseudoindex kept in the BTreeItems obj and the incoming index. Since this incoming index was never legitimately negative as it assumed, actually negatives passed in due to "overshooting" the first item would repeat the items again from the end. Removal of this code corrects the problem.
    
    Unittests which provoke the error in the original code have also been added.
    
    b4ae0a53
BTreeItemsTemplate.c 19.9 KB