Commit 88b592fb by Sebastien Robin

BTreeData: fixed some minor issues with truncate

1 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:
next_key = minKey(offset) try:
if next_key is None: next_key = minKey(offset)
break except ValueError:
del tree[key] break
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])
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!