Re: [Pyobjc-dev] non-default encoding raising an exception over the bridge
Brought to you by:
ronaldoussoren
From: Just v. R. <ju...@le...> - 2003-11-22 10:49:31
|
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? Strongly disagree. This leads to silent errors, possibly even data loss. You _have_ to know the encoding, and you _have_ to deal with it. If there's no way you can know the encoding, you have to explicitly tell which encoding or behavior to use. Btw. it's not so much PyObjC's behavior, but Python's default str -> unicode coercion behavior. Perhaps it's "fixable" in the bridge, but I think it's a bad idea to deviate from Python's behavior (in addition to that I find it a bad idea to begin with). Just |