[Python-Dev] Sneaky 'super' instances

Brett C. drifty@alum.berkeley.edu
2003年6月11日 13:26:50 -0700


Raymond Hettinger wrote:
>>>Bug 729103 discovered an interesting little issue; 'super' instances 
>>>cause inspect.isroutine to return True since it also poses as a non-data 
>>>descriptor. Now this is bad because pydoc then tries to get a __name__ 
>>>attribute out of it which it lacks because it is an instance of a class 
>>>and not really a function or method.
>>>>>>So, should I change inspect.isroutine to check to see if its argument is 
>>>an instance of 'super'? 
>>> That is a reasonable short-term solution but it should go 
> one layer down in ismethoddescriptor(). Append the line:
>> and not isinstance(object, super)
>
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.
-Brett

AltStyle によって変換されたページ (->オリジナル) /