[Zope-Coders] BTrees, Unicode, and Python 2.2

Jeremy Hylton jeremy@zope.com
Tue, 16 Oct 2001 15:43:26 -0400 (EDT)


I'd like to see StandaloneZODB work with Python 2.1 and Python 2.2.
I've been using Python 2.2 for development and it's worked fine.  Some
recent test failures in testBTreesUnicode, though, suggests that we've
got a 2.1 / 2.2 issue to straighten out.

testBTreesUnicode fails on Python 2.2 with this error:
ERROR: check every item of the tree
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib.linux-i686-2.2/BTrees/tests/testBTreesUnicode.py", line 21, in setUp    for k,v in self.data:
UnicodeError: ASCII decoding error: ordinal not in range(128)  

The specific error is caused by passing a Unicode key to an OOBTree.
I can't tell what specifically is going wrong, but expect the error is
raised in C inside PyObject_Compare().

I see a different error with Python 2.1:

ERROR: try to access unicode keys in tree
----------------------------------------------------------------------
Traceback (most recent call last):
  File "lib.linux-i686-2.1/BTrees/tests/testBTreesUnicode.py", line 36, in test2    self.assertEqual(self.tree[self.s], self.data[-1][1])
KeyError: <unprintable instance object>

So the behavior of the BTrees seems to depend on something that has
changed between Python versions.  I'm not really sure what we want the
BTrees code to do, so I'm not sure how to go about fixing these
errors.

We want the tests to succeed with Python 2.1 and Python 2.2, but I'm
not sure how to achieve that.

Jeremy