Commit 88b592fb authored by Sebastien Robin's avatar Sebastien Robin

BTreeData: fixed some minor issues with truncate

parent 9bf60aaf
...@@ -181,10 +181,11 @@ class BTreeData(Persistent): ...@@ -181,10 +181,11 @@ class BTreeData(Persistent):
# It is not possible to drop keys as we iterate when using # It is not possible to drop keys as we iterate when using
# iterkeys, so call minKey repeatedly. # iterkeys, so call minKey repeatedly.
while True: while True:
try:
next_key = minKey(offset) next_key = minKey(offset)
if next_key is None: except ValueError:
break break
del tree[key] del tree[next_key]
if __name__ == '__main__': if __name__ == '__main__':
...@@ -229,3 +230,9 @@ if __name__ == '__main__': ...@@ -229,3 +230,9 @@ if __name__ == '__main__':
data.write('ABCDE', 6) data.write('ABCDE', 6)
check(data, 11, 0, 11, '0123XYABCDE', [0, 5, 8, 10]) check(data, 11, 0, 11, '0123XYABCDE', [0, 5, 8, 10])
data.truncate(7)
check(data, 7, 0, 7, '0123XYA', [0, 5])
data.truncate(5)
check(data, 5, 0, 5, '0123X', [0])
data.truncate(3)
check(data, 3, 0, 3, '012', [0])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment