On 07/08/2011 05:24 PM, Jonathan Slenders wrote:
My feeling is that we should silence TypeError, AttributeError and
KeyError in _resolve_lookup, but only when they occur one frame deep.
I agree with what you propose but AFAIK it's not easy to solve without
doing frame analysis (I'd say that feature is not worth doing such
hacks). That's because of the way `hasattr` is implemented:
def hasattr(obj, attr):
try:
getattr(obj, attr)
return True
except AttributeError:
return False
This code directly mirrors the code found in CPython and implies that
/hasattr "executes" properties/.
So there's no way to figure out whether an attribute exists without
executing the code of properties.
Jonas
--
Django + MongoDB: http://django-mongodb.org
--
You received this message because you are subscribed to the Google Groups "Django
developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en.