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

Andreas Jung Andreas Jung" <andreas@zope.com
Thu, 18 Oct 2001 14:08:40 -0400


Jup, but the problem is in this case a Python problem. 
There must be a bug in the unicode_compare() code in unicodeobject.c.
because it returns of the testcase a wrong value to try_3way_compare()
for identical unicode strings.
Andreas
----- Original Message ----- 
From: "Guido van Rossum" <guido@python.org>
To: "Andreas Jung" <andreas@zope.com>
Cc: <jeremy@zope.com>; <jim@zope.com>; <zope-coders@zope.org>
Sent: Thursday, October 18, 2001 13:50
Subject: Re: [Zope-Coders] Re: BTrees, Unicode, and Python 2.2


> > I tracked the problem down to the TEST_KEY macro in
> > BucketTemplace.c/bucket_get().
> > TEST_KEY is only a macro for PyObject_Compare(). Putting
> > PyObject_Compare inside a wrapper function shows me that it returns
> > -1 (instead of 0) when trying to compare
> > u'dreit\xe4gigen' with u'dreit\xe4gigen'.
> 
> To the author of BucketTemplate.c: PyObject_Compare() can return an
> exception since, oh, Python 1.4 at least, but the code in
> BucketTemplate.c doesn't check for an error.  This is what causes
> Andreas's problem.  I would suggest a specific fix except I don't
> understand the code well enough.  The pattern is easy though: if
> PyObject_Compare() returns a negative value, use PyErr_Occurred() to
> check if an exception happened, and if so, do whatever you do on an
> error (cleanup and return NULL, usually).
> 
> --Guido van Rossum (home page: http://www.python.org/~guido/)
>