[Zope-Coders] Analysis: BTrees and Unicode and Python
Andreas Jung
Andreas Jung" <andreas@zope.com
Fri, 19 Oct 2001 12:10:19 -0400
----- Original Message -----
From: "Jeremy Hylton" <jeremy@zope.com>
To: "Andreas Jung" <andreas@zope.com>
Cc: "Guido van Rossum" <guido@python.org>; "Jim Fulton" <Jim@zope.com>;
<zope-coders@zope.org>
Sent: Friday, October 19, 2001 11:58
Subject: Re: [Zope-Coders] Analysis: BTrees and Unicode and Python
> >>>>> "AJ" == Andreas Jung <andreas@zope.com> writes:
>
> AJ> After lots of debugging here an explanation for the behaviour we
> AJ> have seen in the unittest:
>
> AJ> - The BTrees calls PyCompare_Object() several times before the
> AJ> comparison that failed (unicode vs. unicode)
>
> AJ> - one of these earlier comparision checks a Python string
> AJ> (containing and accented character) against a unicode string
> AJ> and raises a unicode exception (ASCII decoding error: ordinal
> AJ> notr in range(128)). I assume because the default encoding is
> AJ> ascii.
>
> AJ> - there is no check in the BTree code to check for an exception
> AJ> after PyObject_Compare() and so this error got never cleared
>
> Who's going to fix this code?
I think I am going to fix that.
>
> AJ> - when when trying to compare two identical unicode strings,
> AJ> Python calls default_3_way_compare() and runs into the
> AJ> following code:
>
> Is this with 2.1 or 2.2?
2.1.1
> I'm looking at the code in the CVS and can't figure out how we get
> there if we're comparing two Unicode objects, we should always use the
> first test in do_cmp(), because unicode objects have a tp_compare
> defined.
>
Andreas