[Zope-Coders] Weird OOBTree bug found

Guido van Rossum guido@python.org
Fri, 12 Oct 2001 12:31:44 -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.

This probably has to do with the default encoding.  Unicode strings
can be used to match ASCII strings, but not 8-bit strings containing
8-bit characters: the 8-bit characters don't have a known encoding
(not everybody encodes their Python string objects in Latin-1) so the
comparison simply fails.

--Guido van Rossum (home page: http://www.python.org/~guido/)