[Python-Dev] Relaxing Unicode error handling

Martin v. Loewis martin at v.loewis.de
Sat Jan 3 12:46:11 EST 2004


Phillip J. Eby wrote:
> When I've gotten UnicodeErrors, it pointed out an error in my 
> programming that needed to be fixed - i.e., that I forgot what kind of 
> strings I was dealing with, and needed to be explicit about it, or at 
> least use the replace/ignore option *at the point of decoding*. 

I agree, and I would alwise advise not to use the feature I'm proposing.

However, now people say "I have followed this advise, and I got
banana software: matures at the customer. We would rather be certain
that the customer won't see exceptions that we never got in testing".

It is for these users where the feature would be used.


> Or, am I missing the point entirely, and there's some other circumstance 
> where one gets UnicodeErrors besides .decode()?  If the use case is 
> mixing strings and unicode objects (i.e. adding, joining, searching, 
> etc.), then I'd have to say a big fat -1, as opposed to merely a -0 for 
> having other ways to spell .decode(codec,"ignore"). 

Yes, it is these use cases: Somebody invokes an SQL method, which 
happens to return a Unicode string, and then adds a latin-1 byte
string to it. It works for all ASCII byte strings, but then the
customer happens to enter accented characters, and the application
crashes without offering to safe recent changes.

So I guess that's -1 from you.

Regards,
Martin




More information about the Python-Dev mailing list