[zope.interface bug] Re: [Zope-dev] "zope.interface" confuses
Python
Dieter Maurer
dieter at handshake.de
Mon Jan 7 15:54:15 EST 2008
Hello Jim,
Jim Fulton wrote at 2008-1-7 15:15 -0500:
> ....
>> I think I understand the behavior -- and I think it is a
>> "zope.interface"
>> bug.
>
>No, it is intended behavior.
Why?
> ...
>> Under some circumstances "zope.interface" adds a "__provides__"
>> descriptor
>> to a class. The descriptor is implemented in
>> "zope/interface/_zope_interface_coptimizations.c" and called
>> "CPB_descr_get".
>>
>> While "__implements__" is inherited by derived classes,
>> the inherited "__provides__" refuses to work for a derived class
>> and raises "AttributeError: __provides__" instead,
>> the AttriuteError, I observe....
>
>That is intentional.
If "__implements__" is inherited, why is "__provides__" not
inherited?
>> I will try to make my failure independent of "ManagableIndex"
>> and then file a bug report.
>
>
>I'm unclear why this caused a problem for you. You never said, afaict,
>what actually broke for you. What expectation did you have that is
>unsatisfied?
"inspect" does no longer work reliably.
"inspect.getmembers" and "inspect.classify_class_attrs"
require that for each "name" in "dir(cls)" "getattr(cls, name)"
does not raise an exception.
This fails for classes magically stuffed with a "__provides__"
descriptor.
As a consequence, "pydoc" (which sits on top of inspect) fails --
and therefore "dm.zdoc".
>My main gripe with the way this works is that classes get mutated. If
>I ever redo this someday, I'd use a data structure external to the
>classes. Modifying the classes was a mistake.
Yes. That, too, would have avoided the bug.
--
Dieter
More information about the Zope-Dev
mailing list