[Python-Dev] decoding errors when comparing strings

Guido van Rossum guido@beopen.com
Wed, 26 Jul 2000 08:02:02 -0500


> Hmm, so you do want exceptions to be raised for coercion errors
> during compare ?

Sure, fine.

> For the record:
> PyObject_Compare() currently only does coercion for number
> slot compatible types (ok, all Python instances have these
> slots...). Unicode objects are handled in a special case to
> allow the PyUnicode_Compare() API to do all necessary conversions
> and then proceed with the compare.
> 
> The coercion proposal will have to deal with all this in 2.1.
> 
> My version of the proposal (see Python Pages) puts all the power
> into the hands of the operators themselves rather than using 
> a centralized coercion method. In this scenario, the special
> casing in PyObject_Compare() for Unicode would no longer
> be necessary, since the Unicode compare slot could then take
> care of the needed conversions (essentially PyUnicode_Compare()
> would beceom that slot).

This all sounds okay to me -- I've signed off on that design (in
principle) years ago...

--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)