[patch] encodings again

Robert Collins robertc at robertcollins.net
Fri Dec 23 05:37:58 GMT 2005


On Thu, 2005-12-22 at 23:28 -0600, John A Meinel wrote:
> >> +        if hasattr(sys.stdout, "encoding"):
> >> +            output_encoding = sys.stdout.encoding or
> > bzrlib.user_encoding
> >> +        else:
> > 
> > hasattr has problems - avoid it like measles.
> 
> Care to explain what the specific problems are? I've used it before, and
> thought it was better to do a 'has' check, rather than to catch an
> exception. Though you are recommending doing a get, and check vs None.


You should hang on IRC some more :)

16:19 < spiv> mpee: hasattr is effectively "try: getattr(object, name);
return True except: return False"
16:21 < spiv> mpee: Whereas 3-arg getattr only swallows AttributeError.


Rob


-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051223/4364eb19/attachment.pgp 


More information about the bazaar mailing list