Message92691
I was playing about with ideas behind b-plus-trees
and found i python bug
the important bit of code is:
for p, k in enumerate(self.keys):
self.ptrs[p].dump(indent+1, kmin=lk, kmax=k)
print sindent + "(" + str(k) + ")"
lk = k
#
# python bug?
#
show_python_bug = len(sys.argv)>1
if show_python_bug:
#
# why not this?
assert p == len(self.keys)-1
else:
#
# why do I need this instead?
p = len(self.keys)-1
i'm expecting k to still be in scope and equal len(self.keys)-1
sometimes it is and sometimes it isn't (depending on recursion depth)
you can try it for yourselves as I attach the full program:
./btree.py
runs fine
./btree.py show_python_bug
eventually breaks like this:
Traceback (most recent call last):
File "./btree.py", line 235, in <module>
page.dump()
File "./btree.py", line 223, in dump
self.ptrs[p+1].dump(indent+1, kmin=lk)
File "./btree.py", line 223, in dump
self.ptrs[p+1].dump(indent+1, kmin=lk)
File "./btree.py", line 223, in dump
self.ptrs[p+1].dump(indent+1, kmin=lk)
File "./btree.py", line 217, in dump
assert p == len(self.keys)-1
UnboundLocalError: local variable 'p' referenced before assignment
... despite executing that code many times successfully before this
happens ... strange!
I hope you can figure it out and that this report proves helpful. |
|
Date |
User |
Action |
Args |
2009-09-16 15:38:44 | mrdiskodave | set | recipients:
+ mrdiskodave |
2009-09-16 15:38:43 | mrdiskodave | set | messageid: <1253115523.94.0.244610185437.issue6921@psf.upfronthosting.co.za> |
2009-09-16 15:38:42 | mrdiskodave | link | issue6921 messages |
2009-09-16 15:38:40 | mrdiskodave | create | |
|