[Zope-Coders] Analysis: BTrees and Unicode and Python

Jeremy Hylton jeremy@zope.com
Fri, 19 Oct 2001 12:14:26 -0400 (EDT)


>>>>> "GvR" == Guido van Rossum <guido@python.org> writes:

  >> - when when trying to compare two identical unicode strings,
  >>   Python
  >> calls default_3_way_compare() and runs into the following code:
  >>

  >> I am not sure if this code is able to compare two unicode
  >> strings.  On the other hand it is still strange that the unittest
  >> works when replacing the same unicode string in the list with the
  >> testdata in the unittest with self.s as described earlier.
  >>
  >> Any ideas about that ?

  GvR> It is definitely a bug if comparison of two unicode strings
  GvR> ends up calling default_3way_compare()!

  GvR> This normally doesn't happen though -- the Unicode object's
  GvR> comparison code is generally called.

  GvR> I'd like to see what's on the stack when default_3way_compare
  GvR> is called with two Unicode objects.

  GvR> Which Python version is this?  2.1 or 2.1.1?

The execution path is fairly different between 2.1.1 and 2.2, but it
looks like the unicode_compare() function should be used in either
case.

On the other hand, there was a bug fix in 2.1.1 that's not in 2.1 with
a checkin comment that says:

"Fix a bad (albeit unlikely) return value in try_rich_to_3way_compare()."

If try_rich_to_3way_compare() returns bad value, we could end up in
the default case.

Jeremy