Re: [Pyobjc-dev] non-default encoding raising an exception over the bridge
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-11-22 05:08:05
|
On 22 nov 2003, at 4:51, Bob Ippolito wrote: > I think that most of the time, people would be happier if this didn't > raise an exception (use the unicode replace instead). If the python > user doesn't know the encoding of the text, and it's not default > encoding, the developer probably doesn't have anything better than > replace to use on the string. The exception is a nuisance and can be > hard to track down. > > Perhaps this could be a module level variable in objc, so that a > person could toggle it to be strict if they wanted it that way, but > have the default as replace? > > -bob We already have such a variable, it is called defaultencoding and can be set using sys.setdefaultencoding(). This is not exactly what you ask, but IMHO better than what you propose ("Errors should never pass silently."). BTW. You should convert all input to unicode instead of waiting for problems with the implicit conversion to unicode that is performed by PyObjC. You're more likely to know the right encoding while reading the data. Ronald |