[Zope-Coders] Weird OOBTree bug found

Andreas Jung Andreas Jung" <andreas@zope.com
Fri, 12 Oct 2001 12:12:03 -0400


The following code create an OOBTree containing some
strings and unicode strings as keys. Trying to access
the unicode string raises a KeyError although it is
in the tree. When I build the same tree without
the string 'k\xf6nnten' as key I can access the unicode
string in the tree. Funny behaviour but not really useful :-)

The problem occurs with OOBTree from the trunk and 2.4 branch.

Andreas

-----------------------------------------------------


from BTrees.OOBTree import OOBTree

s = unicode('dreit\xe4gigen','latin1')

l=[('alien', 284708388), 
    ('fox', 284708387), 
    ('future', 284708388), 
    ('quick', 284708387), 
    ('k\xf6nnten', 284708389),
    ('zerst\xf6rt', 284708389), 
    (unicode('dreit\xe4gigen','latin1'), 284708391)]


# This fails

t = OOBTree()
for k,v in l: t[k]=v

print map(None,t.items())

try: print t[s]
except: print 'not found'

del l[5]

# this works !

t = OOBTree()
for k,v in l: t[k]=v

print map(None,t.items())

try: print t[s]
except: print 'not found'




    ---------------------------------------------------------------------
   -    Andreas Jung                           Zope Corporation        -
  -   EMail: andreas@zope.com                http://www.zope.com      -
 -  "Python Powered"                       http://www.python.org     - 
  -   "Makers of Zope"                       http://www.zope.org      - 
   -            "Endings are just Beginnings"                          -
    ---------------------------------------------------------------------