Nick Coghlan added the comment:
Indeed, since None is a potentially valid attribute value, the required API for
a descriptor to indicate "no such attribute" in __get__ is to throw
AttributeError.
--
nosy: +ncoghlan
resolution: -> invalid
stage: -> committed/rejected
status: open -> c
Eric Snow added the comment:
You may get unexpected behavior when you have a descriptor on a class that also
has __getattr__ defined. See issue #1615. However, I don't think that applies
here. As far as I can tell, everything is working the way it should.
--
___
Eric Snow added the comment:
Returning None is the right thing here. The default for getattr() is returned
only when it catches an AttributeError (hence the exception is the sentinel, so
to speak, not None. Here's a rough equivalent:
_notset = object()
def getattr(obj, name, default=_no
New submission from Martin Thurau:
If you have a descriptor (in my case it was an SQLAlchemy column) on an
instance and this descriptor returns None for a call to __get__ then getattr
with a given default value, will not return the default, but None.
I have no knowledge on the implementation d