[Zope-Coders] new getattr behaviour in Python 2.2b1 breaks traversal code

Steve Alexander steve@cat-box.net
Mon, 12 Nov 2001 06:00:02 +0000


Barry A. Warsaw wrote:

> 
> - getattr(obj, name, default) now only catches AttributeError, as
>   documented, rather than returning the default value for all
>   exceptions (which could mask bugs in a __getattr__ hook, for
>   example).
> 
> So clearly, Guido intended to make this change.

In that case, I'd like to apply my patch to HTTPRequest.py.

The patch does not break backwards compatibility. It allows __getitem__ 
and __getattr__ to each raise appropriate exceptions, while maintaining 
the shared method body. The only down side is one extra method call when 
calling __getattr__.

Any objections to me checking this into the trunk?

--
Steve Alexander