[Python-Dev] Sneaky 'super' instances

Brett C. drifty@alum.berkeley.edu
Wed, 11 Jun 2003 15:24:01 -0700


Raymond Hettinger wrote:
> [Raymond]
> 
>>>That is a reasonable short-term solution but it should go 
>>>one layer down in ismethoddescriptor().  Append the line:
>>>
>>>    and not isinstance(object, super)
>>>
> 
> 
> [Brett]
> 
>>Even though it is a non-data descriptor?  It seems to have a __get__ 
>>instead of a __call__ method.  The problem is that pydoc just classifies 
>>it as a descriptor first and assumes __name__ will be there.
> 
> 
> Either way is fine.
> 

Then how about both; I patch pydoc, you patch inspect?

> My way solves the original problem and defines methoddescriptor
> as a non-data descriptor that isn't super.  I think that matches what 
> people expect when calling that inspect.ismethoddescriptor().
> 

I never use inspect so if you think that it should be changed that way 
then go for it.

> OTOH, if methoddescriptor is viewed as synonymous with
> non-data descriptor, then, technically a super object should
> return True and your fix will have to go inspect.isroutine().
> 

I decided to catch AttributeError when pydoc checks to see what kind of 
thing an object is and then just pass on the catch and fall through to 
the method it has for when it isn't a module, class, or routine.

> Name your poison.  Add a test case.  Then fix it.

Ah, but there are no tests for pydoc.

-Brett