I think you are right to question this test, and I can't find a way for instance
to be None
in this code either. The documentation also seems to make it clear that instance
can never be None
:
object.__set__(self, instance, value)
Called to set the attribute on an instance
instance
of the owner class to a new value,value
.
My guess is that instance
was checked for None
in __get__
for a good reason, and that the same test ended up in __set__
by sheer mimetism.